aboutsummaryrefslogtreecommitdiff
path: root/examples/05_command_framework
diff options
context:
space:
mode:
authorMaiddog <[email protected]>2017-08-27 17:54:16 -0500
committeralex <[email protected]>2017-08-28 00:54:16 +0200
commit4e360cf86a74051e2d4f98758c65ae29b97b7b8b (patch)
tree6f2a02381b507432b089dbdeeabeb89ff496efe8 /examples/05_command_framework
parentPrevent malformed opus data from crashing the bot process (#149) (diff)
downloadserenity-4e360cf86a74051e2d4f98758c65ae29b97b7b8b.tar.xz
serenity-4e360cf86a74051e2d4f98758c65ae29b97b7b8b.zip
Fix examples (#151)
Diffstat (limited to 'examples/05_command_framework')
-rw-r--r--examples/05_command_framework/src/main.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs
index 6cf5692..d987628 100644
--- a/examples/05_command_framework/src/main.rs
+++ b/examples/05_command_framework/src/main.rs
@@ -15,7 +15,7 @@ extern crate typemap;
use serenity::prelude::*;
use serenity::model::*;
-use serenity::framework::standard::{Command, DispatchError, StandardFramework, help_commands};
+use serenity::framework::standard::{Args, Command, DispatchError, StandardFramework, help_commands};
use std::collections::HashMap;
use std::env;
use std::fmt::Write;
@@ -166,7 +166,7 @@ command!(commands(ctx, msg, _args) {
// In this case, this command checks to ensure you are the owner of the message
// in order for the command to be executed. If the check fails, the command is
// not called.
-fn owner_check(_: &mut Context, msg: &Message, _: &[String], _: &Arc<Command>) -> bool {
+fn owner_check(_: &mut Context, msg: &Message, _: &mut Args, _: &Arc<Command>) -> bool {
// Replace 7 with your ID
msg.author.id == 7
}
@@ -197,7 +197,10 @@ command!(some_long_command(_ctx, msg, args) {
// will be ignored.
//
// Argument type overloading is currently not supported.
-command!(multiply(_ctx, msg, args, first: f64, second: f64) {
+command!(multiply(_ctx, msg, args) {
+ let first = args.single::<f64>().unwrap();
+ let second = args.single::<f64>().unwrap();
+
let res = first * second;
if let Err(why) = msg.channel_id.say(&res.to_string()) {