Added insults and compliments
+ clippy + fmt
This commit is contained in:
+30
-1
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user