use lazy_static::lazy_static; use serenity::{http::Http, model::channel::Message}; 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> { if cfg!(debug_assertions) && *msg.author.id.as_u64() == *BOT_OWNER_ID { Ok(Some( msg.channel_id.say(ctx, format!("DEBUG: {}", resp)).await?, )) } else if !cfg!(debug_assertions) { Ok(Some(msg.channel_id.say(ctx, resp).await?)) } else { Ok(None) } }