diff options
| author | Zeyla Hellyer <[email protected]> | 2017-08-19 09:36:15 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-08-19 09:39:44 -0700 |
| commit | 948b27ce74e8dce458d427d8159f2a821d4d7cec (patch) | |
| tree | bf82bedd1821ca210e4a9f08644581486738aed6 /examples | |
| parent | Add html_root_url (diff) | |
| download | serenity-948b27ce74e8dce458d427d8159f2a821d4d7cec.tar.xz serenity-948b27ce74e8dce458d427d8159f2a821d4d7cec.zip | |
Move builtin framework impl to its own module
The framework is now moved in its entirity to the `framework` module,
with the `Framework` trait currently on its own and the builtin
implementation provided.
The builtin implementation has been renamed to "Standard".
Upgrade path:
Rename the `BuiltinFramework` import to `StandardFramework`. Instead of
importing builtin framework items from `serenity::framework`, import
them from `serenity::framework::standard`.
This is the beginning to #60. The root `framework` module (non-standard
implementation) will be built more by the time it's closed.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/05_command_framework/src/main.rs | 9 | ||||
| -rw-r--r-- | examples/06_voice/src/main.rs | 9 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/main.rs | 4 |
3 files changed, 12 insertions, 10 deletions
diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs index c6c0fe4..6cf5692 100644 --- a/examples/05_command_framework/src/main.rs +++ b/examples/05_command_framework/src/main.rs @@ -15,10 +15,11 @@ extern crate typemap; use serenity::prelude::*; use serenity::model::*; -use serenity::framework::{BuiltinFramework, DispatchError, help_commands}; +use serenity::framework::standard::{Command, DispatchError, StandardFramework, help_commands}; use std::collections::HashMap; use std::env; use std::fmt::Write; +use std::sync::Arc; use typemap::Key; struct CommandCounter; @@ -60,7 +61,7 @@ fn main() { // Refer to the documentation for // `serenity::ext::framework::Configuration` for all available // configurations. - BuiltinFramework::new() + StandardFramework::new() .configure(|c| c .allow_whitespace(true) .on_mention(true) @@ -82,7 +83,7 @@ fn main() { // value of 0. let mut data = ctx.data.lock(); let counter = data.get_mut::<CommandCounter>().unwrap(); - let entry = counter.entry(command_name.clone()).or_insert(0); + let entry = counter.entry(command_name.to_owned()).or_insert(0); *entry += 1; true // if `before` returns false, command processing doesn't happen. @@ -165,7 +166,7 @@ command!(commands(ctx, msg, _args) { // In this case, this command checks to ensure you are the owner of the message // in order for the command to be executed. If the check fails, the command is // not called. -fn owner_check(_: &mut Context, msg: &Message) -> bool { +fn owner_check(_: &mut Context, msg: &Message, _: &[String], _: &Arc<Command>) -> bool { // Replace 7 with your ID msg.author.id == 7 } diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs index 70878ac..d074eb8 100644 --- a/examples/06_voice/src/main.rs +++ b/examples/06_voice/src/main.rs @@ -10,10 +10,11 @@ #[macro_use] extern crate serenity; -use serenity::prelude::*; use serenity::client::CACHE; -use serenity::voice; +use serenity::framework::StandardFramework; use serenity::model::*; +use serenity::prelude::*; +use serenity::voice; use serenity::Result as SerenityResult; use std::env; @@ -31,7 +32,7 @@ fn main() { .expect("Expected a token in the environment"); let mut client = Client::new(&token, Handler); - client.with_framework(|f| f + client.with_framework(StandardFramework::new() .configure(|c| c .prefix("~") .on_mention(true)) @@ -43,7 +44,7 @@ fn main() { .on("ping", ping) .on("undeafen", undeafen) .on("unmute", unmute)); - + let _ = client.start().map_err(|why| println!("Client ended: {:?}", why)); } diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs index 37227cc..7fc415c 100644 --- a/examples/07_sample_bot_structure/src/main.rs +++ b/examples/07_sample_bot_structure/src/main.rs @@ -15,7 +15,7 @@ extern crate serenity; mod commands; use serenity::prelude::*; -use serenity::framework::BuiltinFramework; +use serenity::framework::StandardFramework; use std::env; struct Handler; impl EventHandler for Handler {} @@ -23,7 +23,7 @@ struct Handler; impl EventHandler for Handler {} fn main() { let mut client = Client::new(&env::var("DISCORD_TOKEN").unwrap(), Handler); - client.with_framework(BuiltinFramework::new() + client.with_framework(StandardFramework::new() .configure(|c| c.prefix("~")) .command("ping", |c| c.exec(commands::meta::ping)) .command("latency", |c| c.exec(commands::meta::latency)) |