Added roll command
+ clippy + fmt
This commit is contained in:
parent
a9b5eb43d0
commit
73be6b1d9f
@ -10,6 +10,10 @@ use serenity::framework::standard::{Args, CommandResult};
|
||||
use serenity::model::channel::Message;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[group]
|
||||
#[commands(dad_joke, fortune, roll)]
|
||||
pub struct Joke;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
struct DadJoke {
|
||||
pub id: String,
|
||||
@ -17,10 +21,6 @@ struct DadJoke {
|
||||
pub status: i32,
|
||||
}
|
||||
|
||||
#[group]
|
||||
#[commands(dad_joke, fortune)]
|
||||
pub struct Joke;
|
||||
|
||||
#[command]
|
||||
#[only_in(guilds)]
|
||||
#[aliases("dad")]
|
||||
@ -104,3 +104,20 @@ async fn fortune(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command]
|
||||
#[only_in(guilds)]
|
||||
#[aliases("roll")]
|
||||
#[description("Roll a die!")]
|
||||
async fn roll(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||
let roll = args.rest().parse::<ndm::Dice>();
|
||||
|
||||
let reply = match roll {
|
||||
Ok(roll) => format!("You rolled: **{}**", roll),
|
||||
Err(_) => "Error parsing dice roll".to_string(),
|
||||
};
|
||||
|
||||
msg.reply(&ctx.http, reply).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user