diff options
| author | Zeyla Hellyer <[email protected]> | 2018-08-03 22:21:47 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-08-03 22:38:30 -0700 |
| commit | 602c5a7b78dda42b9c3d5426c39099d48e74bca5 (patch) | |
| tree | 941a16c5b18bcbd7c2bbeb73f5cbbebde3f9a20c /src/framework/standard/configuration.rs | |
| parent | Refactor `command::positions` a little (diff) | |
| download | serenity-602c5a7b78dda42b9c3d5426c39099d48e74bca5.tar.xz serenity-602c5a7b78dda42b9c3d5426c39099d48e74bca5.zip | |
Update Configuration default value listings
Update the default value for each method on the builder, as well as making the
list of default values in the `Default` implementation's documentation
up-to-date.
Diffstat (limited to 'src/framework/standard/configuration.rs')
| -rw-r--r-- | src/framework/standard/configuration.rs | 116 |
1 files changed, 84 insertions, 32 deletions
diff --git a/src/framework/standard/configuration.rs b/src/framework/standard/configuration.rs index f3d66d6..c237286 100644 --- a/src/framework/standard/configuration.rs +++ b/src/framework/standard/configuration.rs @@ -16,6 +16,8 @@ use super::command::PrefixCheck; /// This allows setting configurations like the depth to search for commands, /// whether to treat mentions like a command prefix, etc. /// +/// To see the default values, refer to the [default implementation]. +/// /// # Examples /// /// Responding to mentions and setting a command prefix of `"~"`: @@ -39,6 +41,7 @@ use super::command::PrefixCheck; /// /// [`Client`]: ../../client/struct.Client.html /// [`Framework`]: struct.Framework.html +/// [default implementation]: #impl-Default pub struct Configuration { #[doc(hidden)] pub allow_dm: bool, #[doc(hidden)] pub allow_whitespace: bool, @@ -60,6 +63,8 @@ pub struct Configuration { impl Configuration { /// If set to false, bot will ignore any private messages. + /// + /// **Note**: Defaults to `true`. pub fn allow_dm(mut self, allow_dm: bool) -> Self { self.allow_dm = allow_dm; @@ -96,7 +101,9 @@ impl Configuration { self } - /// HashSet of guild Ids where commands will be ignored. + /// HashSet of channels Ids where commands will be working. + /// + /// **Note**: Defaults to an empty HashSet. /// /// # Examples /// @@ -108,19 +115,21 @@ impl Configuration { /// # /// # impl EventHandler for Handler {} /// # let mut client = Client::new("token", Handler).unwrap(); - /// use serenity::model::id::GuildId; + /// use serenity::model::id::ChannelId; /// use serenity::framework::StandardFramework; /// /// client.with_framework(StandardFramework::new().configure(|c| c - /// .blocked_guilds(vec![GuildId(7), GuildId(77)].into_iter().collect()))); + /// .allowed_channels(vec![ChannelId(7), ChannelId(77)].into_iter().collect()))); /// ``` - pub fn blocked_guilds(mut self, guilds: HashSet<GuildId>) -> Self { - self.blocked_guilds = guilds; + pub fn allowed_channels(mut self, channels: HashSet<ChannelId>) -> Self { + self.allowed_channels = channels; self } - /// HashSet of channels Ids where commands will be working. + /// HashSet of guild Ids where commands will be ignored. + /// + /// **Note**: Defaults to an empty HashSet. /// /// # Examples /// @@ -132,21 +141,24 @@ impl Configuration { /// # /// # impl EventHandler for Handler {} /// # let mut client = Client::new("token", Handler).unwrap(); - /// use serenity::model::id::ChannelId; + /// use serenity::model::id::GuildId; /// use serenity::framework::StandardFramework; /// /// client.with_framework(StandardFramework::new().configure(|c| c - /// .allowed_channels(vec![ChannelId(7), ChannelId(77)].into_iter().collect()))); + /// .blocked_guilds(vec![GuildId(7), GuildId(77)].into_iter().collect()))); /// ``` - pub fn allowed_channels(mut self, channels: HashSet<ChannelId>) -> Self { - self.allowed_channels = channels; + pub fn blocked_guilds(mut self, guilds: HashSet<GuildId>) -> Self { + self.blocked_guilds = guilds; self } /// HashSet of user Ids whose commands will be ignored. + /// /// Guilds owned by user Ids will also be ignored. /// + /// **Note**: Defaults to an empty HashSet. + /// /// # Examples /// /// Create a HashSet in-place: @@ -169,9 +181,12 @@ impl Configuration { self } - /// The default depth of the message to check for commands. Defaults to 5. + /// The default depth of the message to check for commands. + /// /// This determines how "far" into a message to check for a valid command. /// + /// **Note**: Defaults to 5. + /// /// # Examples /// /// If you set a depth of `1`, and make a command of `"music play"`, but @@ -185,6 +200,8 @@ impl Configuration { /// HashSet of command names that won't be run. /// + /// **Note**: Defaults to an empty HashSet. + /// /// # Examples /// /// Ignore a set of commands, assuming they exist: @@ -218,6 +235,8 @@ impl Configuration { /// Return `None` to not have a special prefix for the dispatch, and to /// instead use the inherited prefix. /// + /// **Note**: Defaults to no dynamic prefix check. + /// /// # Examples /// /// If the Id of the channel is divisible by 5, return a prefix of `"!"`, @@ -256,6 +275,8 @@ impl Configuration { /// /// For example, if this is set to false, then the bot will respond to any /// other bots including itself. + /// + /// **Note**: Defaults to `true`. pub fn ignore_bots(mut self, ignore_bots: bool) -> Self { self.ignore_bots = ignore_bots; @@ -263,7 +284,8 @@ impl Configuration { } /// If set to true, bot will ignore all commands called by webhooks. - /// True by default. + /// + /// **Note**: Defaults to `true`. pub fn ignore_webhooks(mut self, ignore_webhooks: bool) -> Self { self.ignore_webhooks = ignore_webhooks; @@ -273,7 +295,7 @@ impl Configuration { /// Whether or not to respond to commands initiated with a mention. Note /// that this can be used in conjunction with [`prefix`]. /// - /// By default this is set to `false`. + /// **Note**: Defaults to `false`. /// /// # Examples /// @@ -308,6 +330,8 @@ impl Configuration { /// A `HashSet` of user Ids checks won't apply to. /// + /// **Note**: Defaults to an empty HashSet. + /// /// # Examples /// /// Create a HashSet in-place: @@ -352,6 +376,8 @@ impl Configuration { /// Sets the prefix to respond to. A prefix can be a string slice of any /// non-zero length. /// + /// **Note**: Defaults to an empty vector. + /// /// # Examples /// /// Assign a basic prefix: @@ -377,6 +403,8 @@ impl Configuration { /// Sets the prefixes to respond to. Each can be a string slice of any /// non-zero length. /// + /// **Note**: Refer to [`prefix`] for the default value. + /// /// # Examples /// /// Assign a set of prefixes the bot can respond to: @@ -393,6 +421,8 @@ impl Configuration { /// client.with_framework(StandardFramework::new().configure(|c| c /// .prefixes(vec!["!", ">", "+"]))); /// ``` + /// + /// [`prefix`]: #method.prefix pub fn prefixes<T: ToString, It: IntoIterator<Item=T>>(mut self, prefixes: It) -> Self { self.prefixes = prefixes.into_iter().map(|x| x.to_string()).collect(); @@ -401,7 +431,10 @@ impl Configuration { /// Sets whether command execution can done without a prefix. Works only in private channels. /// + /// **Note**: Defaults to `false`. + /// /// # Note + /// /// Needs the `cache` feature to be enabled. Otherwise this does nothing. pub fn no_dm_prefix(mut self, b: bool) -> Self { self.no_dm_prefix = b; @@ -411,6 +444,8 @@ impl Configuration { /// Sets a delimiter to be used when splitting the content after a command. /// + /// **Note**: Defaults to a vector with a single element of `" "`. + /// /// # Examples /// /// Have the args be seperated by a comma and a space: @@ -436,6 +471,8 @@ impl Configuration { /// Sets multiple delimiters to be used when splitting the content after a command. /// Additionally cleans the default delimiter from the vector. /// + /// **Note**: Refer to [`delimiter`] for the default value. + /// /// # Examples /// /// Have the args be seperated by a comma and a space; and a regular space: @@ -452,6 +489,8 @@ impl Configuration { /// client.with_framework(StandardFramework::new().configure(|c| c /// .delimiters(vec![", ", " "]))); /// ``` + /// + /// [`delimiter`]: #method.delimiter pub fn delimiters<T: ToString, It: IntoIterator<Item=T>>(mut self, delimiters: It) -> Self { self.delimiters.clear(); self.delimiters @@ -460,9 +499,13 @@ impl Configuration { self } - /// Whether the framework shouldn't care about the user's input if it's: `~command`, - /// `~Command`, `~COMMAND`. - /// Setting this to `true` will result in *all* command names to be case insensitive. + /// Whether the framework shouldn't care about the user's input if it's: + /// `~command`, `~Command`, or `~COMMAND`. + /// + /// Setting this to `true` will result in *all* command names to be case + /// insensitive. + /// + /// **Note**: Defaults to `false`. pub fn case_insensitivity(mut self, cs: bool) -> Self { self.case_insensitive = cs; @@ -473,31 +516,40 @@ impl Configuration { impl Default for Configuration { /// Builds a default framework configuration, setting the following: /// + /// - **allow_dm** to `true` /// - **allow_whitespace** to `false` + /// - **allowed_channels** to an empty HashSet + /// - **blocked_guilds** to an empty HashSet + /// - **blocked_users** to an empty HashSet + /// - **case_insensitive** to `false` + /// - **delimiters** to `vec![" "]` /// - **depth** to `5` - /// - **on_mention** to `false` (basically) - /// - **prefix** to `None` + /// - **disabled_commands** to an empty HashSet + /// - **dynamic_prefix** to no dynamic prefix check + /// - **ignore_bots** to `true` + /// - **ignore_webhooks** to `true` /// - **no_dm_prefix** to `false` - /// - **delimiters** to vec![" "] - /// - **case_insensitive** to `false` + /// - **on_mention** to `false` (basically) + /// - **owners** to an empty HashSet + /// - **prefix** to an empty vector fn default() -> Configuration { Configuration { - depth: 5, - on_mention: None, - dynamic_prefix: None, + allow_dm: true, allow_whitespace: false, - prefixes: vec![], - no_dm_prefix: false, - ignore_bots: true, - owners: HashSet::default(), - blocked_users: HashSet::default(), - blocked_guilds: HashSet::default(), allowed_channels: HashSet::default(), - disabled_commands: HashSet::default(), - allow_dm: true, - ignore_webhooks: true, + blocked_guilds: HashSet::default(), + blocked_users: HashSet::default(), case_insensitive: false, delimiters: vec![" ".to_string()], + depth: 5, + disabled_commands: HashSet::default(), + dynamic_prefix: None, + ignore_bots: true, + ignore_webhooks: true, + no_dm_prefix: false, + on_mention: None, + owners: HashSet::default(), + prefixes: vec![], } } } |