-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
6: feat: add hackban command r=Erik1000 a=cloudybyte Co-authored-by: Ole D <[email protected]>
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters