feat: add channeld ids to env file
This commit is contained in:
parent
6a9af83da2
commit
17dec64596
3 changed files with 30 additions and 15 deletions
|
@ -41,7 +41,10 @@ pub async fn handle(ctx: Context, msg: Message) {
|
||||||
let new_content = format!("Sent by {}\n{}", msg.clone().author, lower_case_content.replace(site, fix));
|
let new_content = format!("Sent by {}\n{}", msg.clone().author, lower_case_content.replace(site, fix));
|
||||||
match utilities::replace_msg(ctx.http.clone(), msg.clone(), new_content).await {
|
match utilities::replace_msg(ctx.http.clone(), msg.clone(), new_content).await {
|
||||||
Ok(_) => {},
|
Ok(_) => {},
|
||||||
Err(e) => send_error(ctx.http.clone(), e.to_string()).await
|
Err(e) => {
|
||||||
|
let _ = send_error(ctx.http.clone(), e.to_string()).await;
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +53,10 @@ pub async fn handle(ctx: Context, msg: Message) {
|
||||||
if random::<u16>() % 10000 == 666 {
|
if random::<u16>() % 10000 == 666 {
|
||||||
match msg.reply(ctx.http(), "Povedz loď").await {
|
match msg.reply(ctx.http(), "Povedz loď").await {
|
||||||
Ok(_) => {},
|
Ok(_) => {},
|
||||||
Err(e) => send_error(ctx.http.clone(), e.to_string()).await
|
Err(e) => {
|
||||||
|
let _ = send_error(ctx.http.clone(), e.to_string()).await;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +84,7 @@ async fn response(http: Arc<Http>, msg: Message) -> bool {
|
||||||
match msg.reply(http.clone(), RESPONSES[num]).await {
|
match msg.reply(http.clone(), RESPONSES[num]).await {
|
||||||
Ok(_) => { return true }
|
Ok(_) => { return true }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
send_error(http, e.to_string()).await;
|
let _ = send_error(http, e.to_string()).await;
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -94,7 +100,7 @@ async fn henlo(http: Arc<Http>, msg: Message) -> bool {
|
||||||
match msg.reply(http.clone(), response).await {
|
match msg.reply(http.clone(), response).await {
|
||||||
Ok(_) => { return true }
|
Ok(_) => { return true }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
send_error(http, e.to_string()).await;
|
let _ = send_error(http, e.to_string()).await;
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ use tenorv2::{tenor, tenor_builder::Tenor, tenor_types::{ContentFilter, MediaFil
|
||||||
pub async fn notice_wrapper(ctx: Context) {
|
pub async fn notice_wrapper(ctx: Context) {
|
||||||
match notice(ctx.http.clone()).await {
|
match notice(ctx.http.clone()).await {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
send_error(ctx.http.clone(), e.to_string()).await;
|
let _ = send_error(ctx.http.clone(), e.to_string()).await;
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
Result::Ok(_) => return
|
Result::Ok(_) => return
|
||||||
|
@ -63,7 +63,7 @@ async fn celebrate_birthday(guild_id: GuildId, user_id: UserId, nick: &str, http
|
||||||
let gif_url = match tenor::get_gif_url(MediaFilter::gif, tenor_response) {
|
let gif_url = match tenor::get_gif_url(MediaFilter::gif, tenor_response) {
|
||||||
Ok(urls) => Some(urls),
|
Ok(urls) => Some(urls),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
send_error(http.clone(), e.to_string()).await;
|
let _ = send_error(http.clone(), e.to_string()).await;
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,25 +2,31 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use serenity::http::Http;
|
use serenity::http::Http;
|
||||||
|
|
||||||
pub async fn send_error(_http: Arc<Http>, msg: String) {
|
pub async fn send_error(_http: Arc<Http>, msg: String) -> anyhow::Result<()> {
|
||||||
println!("ERROR: {msg}");
|
println!("ERROR: {msg}");
|
||||||
|
|
||||||
#[cfg(feature="RELEASE")] {
|
#[cfg(feature="RELEASE")] {
|
||||||
use serenity::all::ChannelId;
|
use serenity::all::ChannelId;
|
||||||
use serenity::all::CreateMessage;
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
use super::security::dotenv_var;
|
||||||
|
use anyhow::Context;
|
||||||
|
|
||||||
match ChannelId::new(1199495008416440491)
|
let channel_id: String = dotenv_var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
||||||
.send_message(_http, CreateMessage::new().content(msg)).await {
|
match ChannelId::new(channel_id.parse::<u64>().unwrap())
|
||||||
Ok(_) => { return; }
|
.say(_http, msg).await {
|
||||||
|
Ok(_) => { return Ok(()); }
|
||||||
Err(_) => { exit(-1) }
|
Err(_) => { exit(-1) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature="RELEASE")]
|
#[cfg(feature="RELEASE")]
|
||||||
pub async fn hello(http: Arc<Http>) {
|
pub async fn hello(http: Arc<Http>) -> anyhow::Result<()> {
|
||||||
use serenity::all::ChannelId;
|
use serenity::all::ChannelId;
|
||||||
|
use anyhow::Context;
|
||||||
|
|
||||||
|
use super::security::dotenv_var;
|
||||||
|
|
||||||
let messages = [
|
let messages = [
|
||||||
"AAAAAAAAAAAAAAAAAAAA",
|
"AAAAAAAAAAAAAAAAAAAA",
|
||||||
|
@ -35,8 +41,11 @@ pub async fn hello(http: Arc<Http>) {
|
||||||
|
|
||||||
let num = rand::random::<usize>() % messages.len();
|
let num = rand::random::<usize>() % messages.len();
|
||||||
|
|
||||||
let channel = ChannelId::new(780439236867653635);
|
let channel_id: String = dotenv_var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
||||||
|
let channel = ChannelId::new(channel_id.parse::<u64>().unwrap());
|
||||||
if let Err(why) = channel.say(http, messages[num]).await {
|
if let Err(why) = channel.say(http, messages[num]).await {
|
||||||
print!("Error sending message: {:?}", why);
|
print!("Error sending message: {:?}", why);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
Loading…
Reference in a new issue