diff options
| author | Illia <[email protected]> | 2016-12-10 22:25:55 +0200 |
|---|---|---|
| committer | zeyla <[email protected]> | 2016-12-10 12:25:55 -0800 |
| commit | e44838f4339b90817b5eba5df16230b02487f0cc (patch) | |
| tree | 8513ab3d9d3f9c8826f85630524cca1e4a7e188d /examples | |
| parent | Fix no-cache+method conditional compiles (diff) | |
| download | serenity-e44838f4339b90817b5eba5df16230b02487f0cc.tar.xz serenity-e44838f4339b90817b5eba5df16230b02487f0cc.zip | |
More config for CreateCommand, add various methods
Adds multiple configurations to the command builder, and adds methods
to various structs.
Context::get_current_user is a shortcut to retrieve the current user
from the cache.
Message::get_member retrieves the member object of the message, if sent
in a guild. Message::is_private checks if the message was sent in a
Group or PrivateChannel.
User::member retrieves the user's member object in a guild by Id;
Adds 6 configurations to the command builder:
- dm_only: whether the command can only be used in direct messages;
- guild_only: whether the command can only be used in guilds;
- help_available: whether the command should be displayed in the help
list;
- max_args: specify the maximum number of arguments a command must be
given;
- min_args: specify the minimum number of arguments a command must be
given;
- required_permissions: the permissions a member must have to be able
to use the command;
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/06_command_framework/src/main.rs | 6 | ||||
| -rw-r--r-- | examples/07_voice/src/main.rs | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/examples/06_command_framework/src/main.rs b/examples/06_command_framework/src/main.rs index 408fb9b..f4a3eea 100644 --- a/examples/06_command_framework/src/main.rs +++ b/examples/06_command_framework/src/main.rs @@ -14,7 +14,7 @@ extern crate typemap; use serenity::client::Context; use serenity::Client; -use serenity::model::Message; +use serenity::model::{Message, permissions}; use std::collections::HashMap; use std::env; use std::fmt::Write; @@ -88,7 +88,9 @@ fn main() { .command("commands", |c| c .check(owner_check) .exec(commands)) - .command("emoji cat", |c| c.exec_str(":cat:")) + .command("emoji cat", |c| c + .exec_str(":cat:") + .required_permissions(permissions::SEND_MESSAGES)) .command("emoji dog", |c| c.exec_str(":dog:")) .command("multiply", |c| c.exec(multiply)) .command("ping", |c| c diff --git a/examples/07_voice/src/main.rs b/examples/07_voice/src/main.rs index 3870f9c..b1acc38 100644 --- a/examples/07_voice/src/main.rs +++ b/examples/07_voice/src/main.rs @@ -243,7 +243,7 @@ fn unmute(context: &Context, message: &Message, _args: Vec<String>) { } /// Checks that a message successfully sent; if not, then logs why to stdout. -#[cfg(feature = "voice")] +#[cfg(feature="voice")] fn check_msg(result: SerenityResult<Message>) { if let Err(why) = result { println!("Error sending message: {:?}", why); |