diff options
| author | Austin Hellyer <[email protected]> | 2016-11-30 07:16:59 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-30 07:16:59 -0800 |
| commit | 18e87b36579e20ed20a9c213c296ac7a57097ea4 (patch) | |
| tree | 581be5f42bef2555b8ffd2d2892523f83d75d9e5 /src/lib.rs | |
| parent | Clarify some docs (diff) | |
| download | serenity-18e87b36579e20ed20a9c213c296ac7a57097ea4.tar.xz serenity-18e87b36579e20ed20a9c213c296ac7a57097ea4.zip | |
Move the example in the readme
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 61 |
1 files changed, 32 insertions, 29 deletions
@@ -29,6 +29,38 @@ //! need to be sure that some information piece is sanctioned by Discord, refer //! to their own documentation. //! +//! # 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 @@ -79,35 +111,6 @@ //! //! - 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`]: ext/cache/struct.Cache.html //! [`Client::login_bot`]: client/struct.Client.html#method.login_bot //! [`Client::login_user`]: client/struct.Client.html#method.login_user |