aboutsummaryrefslogtreecommitdiff
path: root/examples/03_struct_utilities/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-29 20:51:10 -0800
committerAustin Hellyer <[email protected]>2016-11-29 22:27:59 -0800
commit93b990d8d1bc9df69b8e27a3db61da570822aad6 (patch)
tree6305cf635df90681527a8e736f65ff19f21fd8bc /examples/03_struct_utilities/src
parentAdd more shiny readme badges (diff)
downloadserenity-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.rs33
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();
+}