aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-30 07:16:59 -0800
committerAustin Hellyer <[email protected]>2016-11-30 07:16:59 -0800
commit18e87b36579e20ed20a9c213c296ac7a57097ea4 (patch)
tree581be5f42bef2555b8ffd2d2892523f83d75d9e5 /README.md
parentClarify some docs (diff)
downloadserenity-18e87b36579e20ed20a9c213c296ac7a57097ea4.tar.xz
serenity-18e87b36579e20ed20a9c213c296ac7a57097ea4.zip
Move the example in the readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md61
1 files changed, 32 insertions, 29 deletions
diff --git a/README.md b/README.md
index 44c7beb..36b0c9d 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,38 @@ accurate as possible - Discord hosts [official documentation][discord docs]. If
you need to be sure that some information piece is accurate, refer to their
docs.
+# Example Bot
+
+A basic ping-pong bot looks like:
+
+```rust,no-run
+extern crate serenity;
+
+use serenity::client::{Client, Context};
+use serenity::model::Message;
+use std::env;
+
+fn main() {
+ // Login with a bot token from the environment
+ 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", ping));
+
+ // start listening for events by starting a single shard
+ let _ = client.start();
+}
+
+fn ping(_context: Context, message: Message, _args: Vec<String>) {
+ let _ = message.reply("Pong!");
+}
+```
+
+### Full Examples
+
+Full examples, detailing and explaining usage of the basic functionality of the
+library, can be found in the [`examples`] directory.
+
# Features
Features can be enabled or disabled by configuring the library through
@@ -82,35 +114,6 @@ Voice+youtube-dl:
- youtube-dl (Arch: `community/youtube-dl`)
-# Example Bot
-
-A basic ping-pong bot looks like:
-
-```rust,no-run
-extern crate serenity;
-
-use serenity::Client;
-use std::env;
-
-fn main() {
- // Login with a bot token from the environment
- 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, _arguments| {
- let _ = message.reply("Pong!");
- }));
-
- // start listening for events by starting a single shard
- let _ = client.start();
-}
-```
-
-### Full Examples
-
-Full examples, detailing and explaining usage of the basic functionality of the
-library, can be found in the [`examples`] directory.
-
[`Cache`]: https://serenity.zey.moe/serenity/ext/cache/struct.Cache.html
[`Client::login_bot`]: https://serenity.zey.moe/serenity/client/struct.Client.html#method.login_bot
[`Client::login_user`]: https://serenity.zey.moe/serenity/client/struct.Client.html#method.login_user