aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-08 15:45:51 -0800
committerAustin Hellyer <[email protected]>2016-11-08 15:45:51 -0800
commit388eb530c5631f80c245d3d29435ec35379063b5 (patch)
tree3e2574fea3c845b420fe2f2d06b13242e5faca96
parentFramework: fix command arg positioning (diff)
downloadserenity-388eb530c5631f80c245d3d29435ec35379063b5.tar.xz
serenity-388eb530c5631f80c245d3d29435ec35379063b5.zip
Fix README example
-rw-r--r--README.md10
-rw-r--r--src/lib.rs12
2 files changed, 15 insertions, 7 deletions
diff --git a/README.md b/README.md
index 0d94641..0a4d514 100644
--- a/README.md
+++ b/README.md
@@ -48,15 +48,19 @@ A basic ping-pong bot looks like:
extern crate serenity;
use serenity::Client;
+use std::env;
fn main() {
// Login with a bot token from the environment
- let client = Client::login_bot(env::var("DISCORD_TOKEN").expect("token"));
+ let mut client = Client::login_bot(&env::var("DISCORD_TOKEN").expect("token"));
client.with_framework(|f| f
.configure(|c| c.prefix("~")) // set the bot's prefix to "~"
- .on("ping", |_context, message| drop(message.reply("Pong!"))));
+ .on("ping", |_context, message, _arguments| {
+ let _ = message.reply("Pong!");
+ }));
- let _ = client.start(); // start listening for events by starting a connection
+ // start listening for events by starting a connection
+ let _ = client.start();
}
```
diff --git a/src/lib.rs b/src/lib.rs
index 7c0c321..689009c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -48,12 +48,16 @@
//!
//! fn main() {
//! // Login with a bot token from the environment
-//! let mut client = Client::login_bot(&env::var("DISCORD_TOKEN").expect("token"));
+//! let mut client = Client::login_bot(&env::var("DISCORD_TOKEN")
+//! .expect("token"));
//! client.with_framework(|f| f
-//! .configure(|c| c.prefix("~")) // set the bot's prefix to '~'
-//! .on("ping", |_context, message| drop(message.reply("Pong!"))));
+//! .configure(|c| c.prefix("~")) // set the bot's prefix to "~"
+//! .on("ping", |_context, message, _arguments| {
+//! let _ = message.reply("Pong!");
+//! }));
//!
-//! let _ = client.start(); // start listening for events by starting a connection
+//! // start listening for events by starting a connection
+//! let _ = client.start();
//! }
//! ```
//!