diff options
Diffstat (limited to '07_sample_bot_structure/src/commands/math.rs')
-rw-r--r-- | 07_sample_bot_structure/src/commands/math.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/07_sample_bot_structure/src/commands/math.rs b/07_sample_bot_structure/src/commands/math.rs new file mode 100644 index 0000000..ce7beed --- /dev/null +++ b/07_sample_bot_structure/src/commands/math.rs @@ -0,0 +1,18 @@ +use serenity::prelude::*; +use serenity::model::prelude::*; +use serenity::framework::standard::{ + Args, CommandResult, + macros::command, +}; + +#[command] +pub fn multiply(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult { + let one = args.single::<f64>().unwrap(); + let two = args.single::<f64>().unwrap(); + + let product = one * two; + + let _ = msg.channel_id.say(&ctx.http, product); + + Ok(()) +} |