diff options
| author | acdenisSK <[email protected]> | 2017-08-06 13:51:45 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-06 13:53:43 +0200 |
| commit | 9b09481216105cf75375346a6e41edd7d5869e7c (patch) | |
| tree | afb80b707a08f119ce81e21e64ba29bb0b061dc4 /examples/07_sample_bot_structure/src | |
| parent | make Travis test on OS X (#123) (diff) | |
| download | serenity-9b09481216105cf75375346a6e41edd7d5869e7c.tar.xz serenity-9b09481216105cf75375346a6e41edd7d5869e7c.zip | |
Update examples
Diffstat (limited to 'examples/07_sample_bot_structure/src')
| -rw-r--r-- | examples/07_sample_bot_structure/src/commands/math.rs | 2 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/commands/meta.rs | 2 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/main.rs | 9 |
3 files changed, 8 insertions, 5 deletions
diff --git a/examples/07_sample_bot_structure/src/commands/math.rs b/examples/07_sample_bot_structure/src/commands/math.rs index 79bfc52..2b1c1d2 100644 --- a/examples/07_sample_bot_structure/src/commands/math.rs +++ b/examples/07_sample_bot_structure/src/commands/math.rs @@ -1,5 +1,5 @@ command!(multiply(_ctx, msg, _args, one: f64, two: f64) { let product = one * two; - let _ = msg.channel_id.say(&product.to_string()); + let _ = msg.channel_id.say(product); }); diff --git a/examples/07_sample_bot_structure/src/commands/meta.rs b/examples/07_sample_bot_structure/src/commands/meta.rs index a4036fc..fc7c492 100644 --- a/examples/07_sample_bot_structure/src/commands/meta.rs +++ b/examples/07_sample_bot_structure/src/commands/meta.rs @@ -6,7 +6,7 @@ command!(latency(ctx, msg) { format!("{}.{}s", s.as_secs(), s.subsec_nanos()) }); - let _ = msg.channel_id.say(&latency); + let _ = msg.channel_id.say(latency); }); command!(ping(_ctx, msg) { diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs index 42ccd64..37227cc 100644 --- a/examples/07_sample_bot_structure/src/main.rs +++ b/examples/07_sample_bot_structure/src/main.rs @@ -14,13 +14,16 @@ extern crate serenity; mod commands; -use serenity::Client; +use serenity::prelude::*; +use serenity::framework::BuiltinFramework; use std::env; +struct Handler; impl EventHandler for Handler {} + fn main() { - let mut client = Client::new(&env::var("DISCORD_TOKEN").unwrap()); + let mut client = Client::new(&env::var("DISCORD_TOKEN").unwrap(), Handler); - client.with_framework(|f| f + client.with_framework(BuiltinFramework::new() .configure(|c| c.prefix("~")) .command("ping", |c| c.exec(commands::meta::ping)) .command("latency", |c| c.exec(commands::meta::latency)) |