diff options
Diffstat (limited to 'src/commands/optional/teawiespam.rs')
| -rw-r--r-- | src/commands/optional/teawiespam.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/commands/optional/teawiespam.rs b/src/commands/optional/teawiespam.rs index 7f7ba79..3a9a387 100644 --- a/src/commands/optional/teawiespam.rs +++ b/src/commands/optional/teawiespam.rs @@ -1,21 +1,29 @@ -use crate::Context; +use crate::{Context, Error}; -use eyre::Result; use log::debug; /// teawie will spam you. #[poise::command(slash_command)] -pub async fn teawiespam(ctx: Context<'_>) -> Result<()> { - let gid = ctx.guild_id().unwrap_or_default(); - let settings = ctx.data().storage.get_guild_settings(&gid).await?; +pub async fn teawiespam(ctx: Context<'_>) -> Result<(), Error> { + if let Some(guild_id) = ctx.guild_id() { + if let Some(storage) = &ctx.data().storage { + let settings = storage.get_guild_settings(&guild_id).await?; - if !settings.optional_commands_enabled { - debug!("Not running teawiespam in {gid} since it's disabled"); - ctx.say("I'm not allowed to do that here").await?; - return Ok(()); + if !settings.optional_commands_enabled { + debug!("Not running command in {guild_id} since it's disabled"); + ctx.say("I'm not allowed to do that here").await?; + + return Ok(()); + } + } else { + debug!("Ignoring restrictions on command; no storage backend is attached!"); + } + } else { + debug!("Ignoring restrictions on command; we're not in a guild."); } let wies = "<:teawiesmile:1056438046440042546>".repeat(50); ctx.say(wies).await?; + Ok(()) } |
