diff options
| author | Lakelezz <[email protected]> | 2018-10-15 20:48:49 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-10-15 20:48:49 +0200 |
| commit | 6a68f68e6cb95af38666a4f5d9a6ad4b39fa88c6 (patch) | |
| tree | c21576ee8bf06c0e2f208a499a6aa900907e186f /src/framework/standard/configuration.rs | |
| parent | Add Option to disable bypassing Checks for Owners (#419) (diff) | |
| download | serenity-6a68f68e6cb95af38666a4f5d9a6ad4b39fa88c6.tar.xz serenity-6a68f68e6cb95af38666a4f5d9a6ad4b39fa88c6.zip | |
Prefix only Command (#416)
Diffstat (limited to 'src/framework/standard/configuration.rs')
| -rw-r--r-- | src/framework/standard/configuration.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/framework/standard/configuration.rs b/src/framework/standard/configuration.rs index c19b1dd..a8ef075 100644 --- a/src/framework/standard/configuration.rs +++ b/src/framework/standard/configuration.rs @@ -6,9 +6,10 @@ use model::{ }; use std::{ collections::HashSet, - default::Default + default::Default, + sync::Arc, }; -use super::command::PrefixCheck; +use super::command::{Command, InternalCommand, PrefixCheck}; /// The configuration to use for a [`StandardFramework`] associated with a [`Client`] /// instance. @@ -59,6 +60,7 @@ pub struct Configuration { #[doc(hidden)] pub no_dm_prefix: bool, #[doc(hidden)] pub delimiters: Vec<String>, #[doc(hidden)] pub case_insensitive: bool, + #[doc(hidden)] pub prefix_only_cmd: Option<InternalCommand>, } impl Configuration { @@ -511,6 +513,15 @@ impl Configuration { self } + + /// Sets a command to dispatch if user's input is a prefix only. + /// + /// **Note**: Defaults to no command and ignores prefix only. + pub fn prefix_only_cmd<C: Command + 'static>(mut self, c: C) -> Self { + self.prefix_only_cmd = Some(Arc::new(c)); + + self + } } impl Default for Configuration { @@ -550,6 +561,7 @@ impl Default for Configuration { on_mention: None, owners: HashSet::default(), prefixes: vec![], + prefix_only_cmd: None, } } } |