aboutsummaryrefslogtreecommitdiff
path: root/examples/01_basic_ping_bot/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/01_basic_ping_bot/src
parentAdd more shiny readme badges (diff)
downloadserenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.tar.xz
serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.zip
Clean up the codebase
Diffstat (limited to 'examples/01_basic_ping_bot/src')
-rw-r--r--examples/01_basic_ping_bot/src/main.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/01_basic_ping_bot/src/main.rs b/examples/01_basic_ping_bot/src/main.rs
new file mode 100644
index 0000000..8db4614
--- /dev/null
+++ b/examples/01_basic_ping_bot/src/main.rs
@@ -0,0 +1,23 @@
+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 == "!ping" {
+ let _ = context.say("Pong!");
+ }
+ });
+
+ client.on_ready(|_context, ready| {
+ println!("{} is connected!", ready.user.name);
+ });
+
+ let _ = client.start();
+}