Skip to content

Commit

Permalink
Merge #6
Browse files Browse the repository at this point in the history
6: feat: add hackban command r=Erik1000 a=cloudybyte



Co-authored-by: Ole D <[email protected]>
  • Loading branch information
bors[bot] and oleggtro authored Sep 8, 2022
2 parents d8b4206 + 39cbb76 commit 4e10aa8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bot/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
mod invite;
mod moderation;

#[doc(inline)]
pub use invite::invite;
#[doc(inline)]
pub use moderation::hackban;
47 changes: 47 additions & 0 deletions bot/src/commands/moderation.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
) -> 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(())
}
6 changes: 5 additions & 1 deletion bot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 4e10aa8

Please sign in to comment.