diff options
| author | Zeyla Hellyer <[email protected]> | 2017-12-15 21:33:22 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-12-16 08:45:26 -0800 |
| commit | c9efd7c147abfd1f92758719141fbb67d9792271 (patch) | |
| tree | 319f4120d2efbf2748dc8ad9c23c1a14ac9e1872 /examples/07_sample_bot_structure/src | |
| parent | Revamp the internals of `Args` (diff) | |
| download | serenity-c9efd7c147abfd1f92758719141fbb67d9792271.tar.xz serenity-c9efd7c147abfd1f92758719141fbb67d9792271.zip | |
Fix compilation of example 07
Diffstat (limited to 'examples/07_sample_bot_structure/src')
| -rw-r--r-- | examples/07_sample_bot_structure/src/commands/meta.rs | 10 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/commands/owner.rs | 11 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/main.rs | 11 |
3 files changed, 8 insertions, 24 deletions
diff --git a/examples/07_sample_bot_structure/src/commands/meta.rs b/examples/07_sample_bot_structure/src/commands/meta.rs index 18ee48d..49197a8 100644 --- a/examples/07_sample_bot_structure/src/commands/meta.rs +++ b/examples/07_sample_bot_structure/src/commands/meta.rs @@ -1,13 +1,3 @@ -command!(latency(ctx, msg) { - let latency = ctx.shard.lock() - .latency() - .map_or_else(|| "N/A".to_string(), |s| { - format!("{}.{}s", s.as_secs(), s.subsec_nanos()) - }); - - let _ = msg.channel_id.say(latency); -}); - command!(ping(_ctx, msg) { let _ = msg.channel_id.say("Pong!"); }); diff --git a/examples/07_sample_bot_structure/src/commands/owner.rs b/examples/07_sample_bot_structure/src/commands/owner.rs index e80c19d..7836b8f 100644 --- a/examples/07_sample_bot_structure/src/commands/owner.rs +++ b/examples/07_sample_bot_structure/src/commands/owner.rs @@ -1,10 +1,5 @@ command!(quit(ctx, msg, _args) { - match ctx.quit() { - Ok(()) => { - let _ = msg.reply("Shutting down!"); - }, - Err(why) => { - let _ = msg.reply(&format!("Failed to shutdown: {:?}", why)); - }, - } + ctx.quit(); + + let _ = msg.reply("Shutting down!"); }); diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs index 4c0ff8b..5ab06e5 100644 --- a/examples/07_sample_bot_structure/src/main.rs +++ b/examples/07_sample_bot_structure/src/main.rs @@ -28,11 +28,11 @@ use std::env; struct Handler; impl EventHandler for Handler { - fn on_ready(&self, _: Context, ready: Ready) { + fn ready(&self, _: Context, ready: Ready) { info!("Connected as {}", ready.user.name); } - fn on_resume(&self, _: Context, _: ResumedEvent) { + fn resume(&self, _: Context, _: ResumedEvent) { info!("Resumed"); } } @@ -67,11 +67,10 @@ fn main() { .configure(|c| c .owners(owners) .prefix("~")) - .command("ping", |c| c.exec(commands::meta::ping)) - .command("latency", |c| c.exec(commands::meta::latency)) - .command("multiply", |c| c.exec(commands::math::multiply)) + .command("ping", |c| c.cmd(commands::meta::ping)) + .command("multiply", |c| c.cmd(commands::math::multiply)) .command("quit", |c| c - .exec(commands::owner::quit) + .cmd(commands::owner::quit) .owners_only(true))); if let Err(why) = client.start() { |