diff --git a/bot/src/commands.rs b/bot/src/commands.rs index 87808c8..c16ad19 100644 --- a/bot/src/commands.rs +++ b/bot/src/commands.rs @@ -1,4 +1,7 @@ mod invite; +mod moderation; #[doc(inline)] pub use invite::invite; +#[doc(inline)] +pub use moderation::hackban; diff --git a/bot/src/commands/moderation.rs b/bot/src/commands/moderation.rs new file mode 100644 index 0000000..9f9ce50 --- /dev/null +++ b/bot/src/commands/moderation.rs @@ -0,0 +1,47 @@ +use poise::serenity_prelude::{Color, UserId}; + +use crate::{Context, Result}; + +/// Moderate stuff +#[command( + slash_command, + guild_only, + required_permissions = "BAN_MEMBERS", + required_bot_permissions = "BAN_MEMBERS" +)] +pub async fn hackban( + ctx: Context<'_>, + #[description = "The member you want to ban"] user: UserId, + reason: Option, +) -> Result<()> { + if let Some(ref reason) = reason { + ctx.guild() + .unwrap() + .ban_with_reason(&ctx.discord().http, user, 0, reason) + .await?; + } else { + ctx.guild() + .unwrap() + .ban(&ctx.discord().http, user, 0) + .await?; + } + ctx.send(|b| { + b.ephemeral(true); + b.embed(|e| { + e.color(Color::DARK_GREEN); + e.title("Banned 🚫"); + if let Some(reason) = reason { + e.description(format!( + "User `{}` got banned for reason `{}`", + user, reason + )); + } else { + e.description(format!("User `{}` got banned", user)); + } + e + }); + b + }) + .await?; + Ok(()) +} diff --git a/bot/src/main.rs b/bot/src/main.rs index 58a978b..2c06113 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -85,7 +85,11 @@ async fn main() -> anyhow::Result<()> { ..Default::default() }, owners, - commands: vec![register::register(), commands::invite()], + commands: vec![ + register::register(), + commands::invite(), + commands::hackban(), + ], ..Default::default() }, data: data.clone(),