diff options
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/general/ask.rs | 1 | ||||
| -rw-r--r-- | src/commands/general/bing.rs | 1 | ||||
| -rw-r--r-- | src/commands/general/convert.rs | 1 | ||||
| -rw-r--r-- | src/commands/general/random.rs | 1 | ||||
| -rw-r--r-- | src/commands/mod.rs | 2 | ||||
| -rw-r--r-- | src/commands/moderation/actions.rs | 7 | ||||
| -rw-r--r-- | src/commands/moderation/config.rs | 30 | ||||
| -rw-r--r-- | src/commands/optional/copypasta.rs | 8 | ||||
| -rw-r--r-- | src/commands/optional/teawiespam.rs | 6 |
9 files changed, 32 insertions, 25 deletions
diff --git a/src/commands/general/ask.rs b/src/commands/general/ask.rs index 4bbf82e..e1f008a 100644 --- a/src/commands/general/ask.rs +++ b/src/commands/general/ask.rs @@ -1,4 +1,5 @@ use crate::{consts, utils, Context}; + use color_eyre::eyre::{Context as _, Result}; /// ask teawie a question! diff --git a/src/commands/general/bing.rs b/src/commands/general/bing.rs index fefbaf1..b80ebca 100644 --- a/src/commands/general/bing.rs +++ b/src/commands/general/bing.rs @@ -1,4 +1,5 @@ use crate::Context; + use color_eyre::eyre::Result; /// make sure the wie is alive diff --git a/src/commands/general/convert.rs b/src/commands/general/convert.rs index 60135c4..cbbf8dc 100644 --- a/src/commands/general/convert.rs +++ b/src/commands/general/convert.rs @@ -1,4 +1,5 @@ use crate::Context; + use bottomify::bottom; use color_eyre::eyre::Result; diff --git a/src/commands/general/random.rs b/src/commands/general/random.rs index 9aa282a..9595d09 100644 --- a/src/commands/general/random.rs +++ b/src/commands/general/random.rs @@ -1,4 +1,5 @@ use crate::{api, consts, utils, Context}; + use color_eyre::eyre::Result; #[poise::command(slash_command, subcommands("lore", "teawie", "shiggy"))] diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 5e6419c..833df38 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -20,6 +20,6 @@ pub fn to_global_commands() -> Vec<Command<Data, Report>> { ] } -pub fn to_guild_commands() -> Vec<Command<Data, Report>> { +pub fn to_optional_commands() -> Vec<Command<Data, Report>> { vec![optional::copypasta(), optional::teawiespam()] } diff --git a/src/commands/moderation/actions.rs b/src/commands/moderation/actions.rs index 1050656..4d4d0f8 100644 --- a/src/commands/moderation/actions.rs +++ b/src/commands/moderation/actions.rs @@ -2,6 +2,7 @@ use crate::colors::Colors; use crate::Context; use color_eyre::eyre::{eyre, Result}; +use log::*; use poise::serenity_prelude::{CreateEmbed, User}; fn create_moderation_embed( @@ -23,7 +24,7 @@ fn create_moderation_embed( |e: &mut CreateEmbed| e.title(title).fields(fields).color(Colors::Red) } -// ban a user +/// ban a user #[poise::command( slash_command, prefix_command, @@ -42,6 +43,7 @@ pub async fn ban_user( let reason = reason.unwrap_or("n/a".to_string()); + debug!("Banning user {} with reason {reason}", user.id); if reason != "n/a" { guild.ban_with_reason(ctx, &user, days, &reason).await?; } else { @@ -55,7 +57,7 @@ pub async fn ban_user( Ok(()) } -// kick a user +/// kick a user #[poise::command( slash_command, prefix_command, @@ -68,6 +70,7 @@ pub async fn kick_user(ctx: Context<'_>, user: User, reason: Option<String>) -> let reason = reason.unwrap_or("n/a".to_string()); + debug!("Kicking user {} for reason {reason}", user.id); if reason != "n/a" { guild.kick_with_reason(ctx, &user, &reason).await?; } else { diff --git a/src/commands/moderation/config.rs b/src/commands/moderation/config.rs index 2d1410c..d64c4cc 100644 --- a/src/commands/moderation/config.rs +++ b/src/commands/moderation/config.rs @@ -1,5 +1,5 @@ -use crate::settings::{Settings, SettingsProperties}; -use crate::Context; +use crate::{storage, Context}; +use storage::SettingsProperties; use color_eyre::eyre::{eyre, Context as _, ContextCompat, Result}; use log::*; @@ -33,9 +33,9 @@ pub async fn set( #[description = "Enables 'extra' commands like teawiespam and copypasta. Defaults to false."] optional_commands_enabled: Option<bool>, ) -> Result<()> { - let redis = &ctx.data().redis; + let storage = &ctx.data().storage; let gid = ctx.guild_id().unwrap_or_default(); - let mut settings = Settings::from_redis(redis, &gid).await?; + let mut settings = storage.get_guild_settings(&gid).await?; let previous_settings = settings.clone(); if let Some(channel) = pinboard_channel { @@ -48,24 +48,21 @@ pub async fn set( settings.pinboard_watch = Some(prev); } else { let new = Vec::from([watch.id]); - debug!("Setting pinboard_watch to {new:#?} for {} in Redis", gid); + debug!("Setting pinboard_watch to {new:#?} for {}", gid); settings.pinboard_watch = Some(new); } } if let Some(channel) = reactboard_channel { - debug!( - "Setting reactboard_channel to {channel} for {} in Redis", - gid - ); + debug!("Setting reactboard_channel to {channel} for {}", gid); settings.reactboard_channel = Some(channel.id); } if let Some(requirement) = reactboard_requirement { debug!( - "Setting reactboard_requirement to {requirement} for {} in Redis", + "Setting reactboard_requirement to {requirement} for {}", gid ); @@ -82,25 +79,24 @@ pub async fn set( settings.reactboard_reactions = Some(prev); } else { let new = Vec::from([emoji]); - debug!("Setting pinboard_watch to {new:#?} for {} in Redis", gid); + debug!("Setting pinboard_watch to {new:#?} for {}", gid); settings.reactboard_reactions = Some(new); } } if let Some(enabled) = optional_commands_enabled { - debug!( - "Setting optional_commands_enabled to {enabled} for {} in Redis", - gid - ); + debug!("Setting optional_commands_enabled to {enabled} for {}", gid); settings.optional_commands_enabled = enabled; } if previous_settings != settings { - settings.save(redis).await?; + debug!("Updating settings key for {gid}"); + storage.create_settings_key(settings).await?; ctx.reply("Configuration updated!").await?; } else { + debug!("Not updating settings key for {gid} since no changes were made"); ctx.reply("No changes made, so i'm not updating anything") .await?; } @@ -117,7 +113,7 @@ pub async fn get( .guild_id() .wrap_err_with(|| eyre!("Failed to get GuildId from context!"))?; - let settings = Settings::from_redis(&ctx.data().redis, gid).await?; + let settings = ctx.data().storage.get_guild_settings(gid).await?; let value = match setting { SettingsProperties::GuildId => settings.guild_id.to_string(), diff --git a/src/commands/optional/copypasta.rs b/src/commands/optional/copypasta.rs index ea23f5f..289a936 100644 --- a/src/commands/optional/copypasta.rs +++ b/src/commands/optional/copypasta.rs @@ -1,4 +1,4 @@ -use crate::{Context, Settings}; +use crate::Context; use std::collections::HashMap; @@ -66,11 +66,13 @@ pub async fn copypasta( ctx: Context<'_>, #[description = "the copypasta you want to send"] copypasta: Copypastas, ) -> Result<()> { + debug!("Running copypasta command with copypasta {copypasta}"); + let gid = ctx.guild_id().unwrap_or_default(); - let settings = Settings::from_redis(&ctx.data().redis, &gid).await?; + let settings = ctx.data().storage.get_guild_settings(&gid).await?; if !settings.optional_commands_enabled { - debug!("Not running copypasta command in {gid} since it's disabled"); + debug!("Exited copypasta command in {gid} since it's disabled"); return Ok(()); } diff --git a/src/commands/optional/teawiespam.rs b/src/commands/optional/teawiespam.rs index c1b3b29..bb8f32d 100644 --- a/src/commands/optional/teawiespam.rs +++ b/src/commands/optional/teawiespam.rs @@ -1,4 +1,4 @@ -use crate::{Context, Settings}; +use crate::Context; use color_eyre::eyre::Result; use log::*; @@ -6,8 +6,10 @@ use log::*; /// teawie will spam you. #[poise::command(slash_command, prefix_command)] pub async fn teawiespam(ctx: Context<'_>) -> Result<()> { + debug!("Running teawiespam command"); + let gid = ctx.guild_id().unwrap_or_default(); - let settings = Settings::from_redis(&ctx.data().redis, &gid).await?; + let settings = ctx.data().storage.get_guild_settings(&gid).await?; if !settings.optional_commands_enabled { debug!("Not running teawiespam in {gid} since it's disabled"); |
