From e44838f4339b90817b5eba5df16230b02487f0cc Mon Sep 17 00:00:00 2001 From: Illia Date: Sat, 10 Dec 2016 22:25:55 +0200 Subject: 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; --- examples/06_command_framework/src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples/06_command_framework/src/main.rs') 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 -- cgit v1.2.3