diff options
| author | Austin Hellyer <[email protected]> | 2016-11-29 20:51:10 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-29 22:27:59 -0800 |
| commit | 93b990d8d1bc9df69b8e27a3db61da570822aad6 (patch) | |
| tree | 6305cf635df90681527a8e736f65ff19f21fd8bc /examples/03_struct_utilities/src | |
| parent | Add more shiny readme badges (diff) | |
| download | serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.tar.xz serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.zip | |
Clean up the codebase
Diffstat (limited to 'examples/03_struct_utilities/src')
| -rw-r--r-- | examples/03_struct_utilities/src/main.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/03_struct_utilities/src/main.rs b/examples/03_struct_utilities/src/main.rs new file mode 100644 index 0000000..6bf436d --- /dev/null +++ b/examples/03_struct_utilities/src/main.rs @@ -0,0 +1,33 @@ +//! Requires the 'methods' feature flag be enabled in your project's Cargo.toml. +//! +//! This can be activated by specifying the feature in the dependency section: +//! +//! ```toml +//! [dependencies.serenity] +//! git = "https://github.com/zeyla/serenity.rs.git" +//! features = ["methods"] +//! ``` + +extern crate serenity; + +use serenity::Client; +use std::env; + +fn main() { + // Configure the client with your Discord bot token in the environment. + let token = env::var("DISCORD_TOKEN") + .expect("Expected a token in the environment"); + let mut client = Client::login_bot(&token); + + client.on_message(|_context, message| { + if message.content == "!messageme" { + let _ = message.author.dm("Hello!"); + } + }); + + client.on_ready(|_context, ready| { + println!("{} is connected!", ready.user.name); + }); + + let _ = client.start(); +} |