Added insults and compliments

+ clippy + fmt
This commit is contained in:
2022-12-30 22:33:48 -06:00
parent 65ea879ffa
commit 7c9cb2a81f
5 changed files with 67 additions and 1 deletions
+30 -1
View File
@@ -12,7 +12,7 @@ use std::collections::HashMap;
use std::time::Duration;
#[group]
#[commands(dad_joke, roll, bad_apple)]
#[commands(dad_joke, roll, bad_apple, insult)]
pub struct Joke;
#[derive(Clone, Serialize, Deserialize)]
@@ -165,3 +165,32 @@ async fn bad_apple(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
Ok(())
}
#[command]
#[aliases("compliment")]
#[only_in(guilds)]
async fn insult(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let data = ctx.data.read().await;
let global = data.get::<GlobalData>().unwrap();
let selection = if msg.content.as_str().starts_with("!insult") {
&global.cfg.insults
} else if msg.content.as_str().starts_with("!compliment") {
&global.cfg.compliments
} else {
msg.reply(&ctx, "The h*ck did you just say to me??").await?;
return Ok(());
};
let target = args.rest();
let output = selection
.iter()
.choose(&mut thread_rng())
.unwrap()
.render(target)?;
msg.reply(&ctx.http, output).await?;
Ok(())
}