use lazy_static::lazy_static; use serenity::{ http::Http, model::{channel::Message, id::ChannelId}, }; use std::env::var; pub mod db; pub mod error; lazy_static! { static ref BOT_OWNER_ID: u64 = var("BOT_OWNER_ID") .unwrap_or_else(|_| { log::warn!("`BOT_OWNER_ID` env var missing, bot will never respond in debug mode!"); String::new() }) .parse() .unwrap_or_else(|_| { log::error!( "`BOT_OWNER_ID` env var is not a valid u64! Bot will never respond in debug mode!" ); 0 }); } pub async fn debug_say( msg: &Message, ctx: impl AsRef, resp: impl std::fmt::Display, ) -> Result, serenity::Error> { debug_channel_say(&msg.channel_id, *msg.author.id.as_u64(), ctx, resp).await } pub async fn debug_channel_say( channel: &ChannelId, author_id: u64, ctx: impl AsRef, resp: impl std::fmt::Display, ) -> Result, serenity::Error> { if cfg!(debug_assertions) && author_id == *BOT_OWNER_ID { Ok(Some(channel.say(ctx, format!("DEBUG: {}", resp)).await?)) } else if !cfg!(debug_assertions) { Ok(Some(channel.say(ctx, resp).await?)) } else { Ok(None) } }