this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: purge command

isabel fa788988 461dcc3b

+23
+1
src/commands/moderation/mod.rs
··· 1 1 pub mod ban; 2 2 pub mod kick; 3 + pub mod purge; 3 4 pub mod timeout;
+21
src/commands/moderation/purge.rs
··· 1 + use crate::types::Context; 2 + use crate::Result; 3 + use poise::serenity_prelude::GetMessages; 4 + 5 + #[poise::command(slash_command, guild_only, required_permissions = "BAN_MEMBERS")] 6 + pub async fn purge(ctx: Context<'_>, messages_count: Option<u8>) -> Result<()> { 7 + let amount = messages_count.unwrap_or(10); 8 + let current_channel = ctx.channel_id(); 9 + for message in current_channel 10 + .messages(&ctx, GetMessages::new().before(ctx.id()).limit(amount)) 11 + .await? 12 + { 13 + message.delete(&ctx).await?; 14 + } 15 + 16 + ctx.say(format!( 17 + "Successfully purged `{amount}` messages from this channel" 18 + )) 19 + .await?; 20 + Ok(()) 21 + }
+1
src/main.rs
··· 38 38 // moderation commands 39 39 commands::moderation::ban::ban(), 40 40 commands::moderation::kick::kick(), 41 + commands::moderation::purge::purge(), 41 42 commands::moderation::timeout::timeout(), 42 43 // commands for nix 43 44 commands::nix::nixpkgs::nixpkgs(),