diff options
| author | Mishio595 <[email protected]> | 2018-11-13 22:23:39 -0700 |
|---|---|---|
| committer | Mishio595 <[email protected]> | 2018-11-13 22:23:39 -0700 |
| commit | 1dad6996d8e9c983dc9e1689a93dbef5b0696c22 (patch) | |
| tree | 1ee7226178cae76b20e6adcdc7e7cfcc3c477c32 /src/framework/standard/command.rs | |
| parent | Finish rebase (diff) | |
| parent | Make `Region`s `Japan`-variant lowercase. (diff) | |
| download | serenity-1dad6996d8e9c983dc9e1689a93dbef5b0696c22.tar.xz serenity-1dad6996d8e9c983dc9e1689a93dbef5b0696c22.zip | |
Merge branch 'upstream'
Diffstat (limited to 'src/framework/standard/command.rs')
| -rw-r--r-- | src/framework/standard/command.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index 2b1149e..5345f4b 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -60,6 +60,7 @@ impl HelpCommand for Help { pub type BeforeHook = Fn(&mut Context, &Message, &str) -> bool + Send + Sync + 'static; pub type AfterHook = Fn(&mut Context, &Message, &str, Result<(), Error>) + Send + Sync + 'static; pub type UnrecognisedCommandHook = Fn(&mut Context, &Message, &str) + Send + Sync + 'static; +pub type MessageWithoutCommandHook = Fn(&mut Context, &Message) + Send + Sync + 'static; pub(crate) type InternalCommand = Arc<Command>; pub type PrefixCheck = Fn(&mut Context, &Message) -> Option<String> + Send + Sync + 'static; @@ -81,7 +82,7 @@ impl fmt::Debug for CommandOrAlias { #[derive(Clone, Debug)] pub struct Error(pub String); -// TODO: Have seperate `From<(&)String>` and `From<&str>` impls via specialization +// TODO: Have separate `From<(&)String>` and `From<&str>` impls via specialization impl<D: fmt::Display> From<D> for Error { fn from(d: D) -> Self { Error(d.to_string()) @@ -99,6 +100,7 @@ pub struct CommandGroup { pub help_available: bool, pub dm_only: bool, pub guild_only: bool, + pub owner_privileges: bool, pub owners_only: bool, pub help: Option<Arc<Help>>, /// A set of checks to be called prior to executing the command-group. The checks @@ -117,6 +119,7 @@ impl Default for CommandGroup { required_permissions: Permissions::empty(), dm_only: false, guild_only: false, + owner_privileges: true, help_available: true, owners_only: false, allowed_roles: Vec::new(), @@ -141,7 +144,7 @@ pub struct CommandOptions { pub example: Option<String>, /// Command usage schema, used by other commands. pub usage: Option<String>, - /// Minumum amount of arguments that should be passed. + /// Minimum amount of arguments that should be passed. pub min_args: Option<i32>, /// Maximum amount of arguments that can be passed. pub max_args: Option<i32>, @@ -155,6 +158,8 @@ pub struct CommandOptions { pub dm_only: bool, /// Whether command can be used only in guilds or not. pub guild_only: bool, + /// Whether the command treats owners as normal users. + pub owner_privileges: bool, /// Whether command can only be used by owners or not. pub owners_only: bool, /// Other names that can be used to call this command instead. @@ -216,7 +221,7 @@ pub struct HelpOptions { pub wrong_channel: HelpBehaviour, /// Colour help-embed will use upon encountering an error. pub embed_error_colour: Colour, - /// Colour help-embed will use if no error occured. + /// Colour help-embed will use if no error occurred. pub embed_success_colour: Colour, /// If not 0, help will check whether a command is similar to searched named. pub max_levenshtein_distance: usize, @@ -335,6 +340,7 @@ impl Default for CommandOptions { required_permissions: Permissions::empty(), dm_only: false, guild_only: false, + owner_privileges: true, help_available: true, owners_only: false, allowed_roles: Vec::new(), @@ -374,7 +380,8 @@ pub fn positions(ctx: &mut Context, msg: &Message, conf: &Configuration) -> Opti // If the above do not fill `positions`, then that means no kind of prefix was present. // Check if a no-prefix-execution is applicable. - if conf.no_dm_prefix && private && positions.is_empty() { + if conf.no_dm_prefix && private && positions.is_empty() && + !(conf.ignore_bots && msg.author.bot) { positions.push(0); } } |