Skip to content

Commit

Permalink
add ban gambling command
Browse files Browse the repository at this point in the history
  • Loading branch information
ana_rchy committed Jun 20, 2024
1 parent 4c216fe commit 8508dec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,25 @@ pub async fn get_leaderboard(ctx: Context<'_>, param: Option<String>) -> Result<

Ok(())
}


#[poise::command(slash_command, prefix_command, required_bot_permissions = "BAN_MEMBERS")]
pub async fn roll_ban(ctx: Context<'_>) -> Result<(), Error> {
let roll = (rand::random::<u32>() % 1000000) + 1;
let roll_text = format!("roll: {roll}/1000000");

if roll == 1000000 {
let member = ctx.author_member().await.unwrap();
member.ban_with_reason(ctx.http(), 0, "gg you won the lottery").await?;

let message =
format!("{roll_text}\n{} has won the lottery and been BANISHED from these sacred lands", member.user.name);
ctx.say(message).await?;
} else {
let message =
format!("{roll_text}\nno ban, try again");
ctx.say(message).await?;
}

Ok(())
}
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ async fn main() -> Result<(), Error> {

pub async fn poise_setup(shared_data: &SharedData) -> serenity::Client {
let token = std::env::var("DISCORD_TOKEN").expect("envvar the DISCORD_TOKEN");
let intents = GatewayIntents::GUILDS | GatewayIntents::GUILD_MEMBERS | GatewayIntents::MESSAGE_CONTENT
let intents = GatewayIntents::GUILDS
| GatewayIntents::GUILD_MEMBERS
| GatewayIntents::MESSAGE_CONTENT
| GatewayIntents::GUILD_MESSAGES;

let sunset_time = shared_data.sunset_time.clone();
Expand All @@ -52,7 +54,7 @@ pub async fn poise_setup(shared_data: &SharedData) -> serenity::Client {
})
})
.options(poise::FrameworkOptions {
commands: vec![fact_check(), get_leaderboard(), roll(), uwuify()],
commands: vec![fact_check(), get_leaderboard(), roll(), uwuify(), roll_ban()],
prefix_options: poise::PrefixFrameworkOptions {
prefix: Some("!".into()),
..Default::default()
Expand Down

0 comments on commit 8508dec

Please sign in to comment.