diff options
Diffstat (limited to 'examples/07_sample_bot_structure/src/main.rs')
| -rw-r--r-- | examples/07_sample_bot_structure/src/main.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs new file mode 100644 index 0000000..85600eb --- /dev/null +++ b/examples/07_sample_bot_structure/src/main.rs @@ -0,0 +1,32 @@ +//! Requires the 'framework' feature flag be enabled in your project's +//! `Cargo.toml`. +//! +//! This can be enabled by specifying the feature in the dependency section: +//! +//! ```toml +//! [dependencies.serenity] +//! git = "https://github.com/zeyla/serenity.git" +//! features = ["framework"] +//! ``` + +#[macro_use] +extern crate serenity; + +mod commands; + +use serenity::Client; +use std::env; + +fn main() { + let mut client = Client::login(&env::var("DISCORD_TOKEN").unwrap()); + + client.with_framework(|f| f + .configure(|c| c.prefix("~")) + .command("ping", |c| c.exec(commands::meta::ping)) + .command("latency", |c| c.exec(commands::meta::latency)) + .command("multiply", |c| c.exec(commands::math::multiply))); + + if let Err(why) = client.start() { + println!("Client error: {:?}", why); + } +} |