@@ -101,24 +101,56 @@ impl From<(bool, bool, bool)> for WithWhiteSpace {
101101/// [`Client`]: crate::Client
102102/// [`StandardFramework`]: super::StandardFramework
103103/// [default implementation]: Self::default
104+ #[ bool_to_bitflags:: bool_to_bitflags(
105+ getter_prefix = "get_" ,
106+ setter_prefix = "" ,
107+ private_getters,
108+ document_setters,
109+ owning_setters
110+ ) ]
104111#[ derive( Clone ) ]
105112pub struct Configuration {
106- pub ( crate ) allow_dm : bool ,
107113 pub ( crate ) with_whitespace : WithWhiteSpace ,
108- pub ( crate ) by_space : bool ,
109114 pub ( crate ) blocked_guilds : HashSet < GuildId > ,
110115 pub ( crate ) blocked_users : HashSet < UserId > ,
111116 pub ( crate ) allowed_channels : HashSet < ChannelId > ,
112117 pub ( crate ) disabled_commands : HashSet < String > ,
113118 pub ( crate ) dynamic_prefixes : Vec < DynamicPrefixHook > ,
114- pub ( crate ) ignore_bots : bool ,
115- pub ( crate ) ignore_webhooks : bool ,
116119 pub ( crate ) on_mention : Option < String > ,
117120 pub ( crate ) owners : HashSet < UserId > ,
118121 pub ( crate ) prefixes : Vec < String > ,
119- pub ( crate ) no_dm_prefix : bool ,
120122 pub ( crate ) delimiters : Vec < Delimiter > ,
121- pub ( crate ) case_insensitive : bool ,
123+ /// If set to false, bot will ignore any private messages.
124+ ///
125+ /// **Note**: Defaults to `true`.
126+ pub allow_dm : bool ,
127+ /// Whether the framework should split the message by a space first to parse the group or
128+ /// command. If set to false, it will only test part of the message by the *length* of the
129+ /// group's or command's names.
130+ ///
131+ /// **Note**: Defaults to `true`
132+ pub by_space : bool ,
133+ /// Whether the bot should respond to other bots.
134+ ///
135+ /// For example, if this is set to false, then the bot will respond to any other bots including
136+ /// itself.
137+ ///
138+ /// **Note**: Defaults to `true`.
139+ pub ignore_bots : bool ,
140+ /// If set to true, bot will ignore all commands called by webhooks.
141+ ///
142+ /// **Note**: Defaults to `true`.
143+ pub ignore_webhooks : bool ,
144+ /// Sets whether command execution can be done without a prefix. Works only in private
145+ /// channels.
146+ ///
147+ /// **Note**: Defaults to `false`.
148+ ///
149+ /// # Note
150+ ///
151+ /// The `cache` feature is required. If disabled this does absolutely nothing.
152+ pub no_dm_prefix : bool ,
153+ case_insensitive : bool ,
122154}
123155
124156impl Configuration {
@@ -128,15 +160,6 @@ impl Configuration {
128160 Self :: default ( )
129161 }
130162
131- /// If set to false, bot will ignore any private messages.
132- ///
133- /// **Note**: Defaults to `true`.
134- #[ must_use]
135- pub fn allow_dm ( mut self , allow_dm : bool ) -> Self {
136- self . allow_dm = allow_dm;
137- self
138- }
139-
140163 /// Whether to allow whitespace being optional between a prefix/group-prefix/command and a
141164 /// command.
142165 ///
@@ -165,17 +188,6 @@ impl Configuration {
165188 self
166189 }
167190
168- /// Whether the framework should split the message by a space first to parse the group or
169- /// command. If set to false, it will only test part of the message by the *length* of the
170- /// group's or command's names.
171- ///
172- /// **Note**: Defaults to `true`
173- #[ must_use]
174- pub fn by_space ( mut self , b : bool ) -> Self {
175- self . by_space = b;
176- self
177- }
178-
179191 /// HashSet of channels Ids where commands will be working.
180192 ///
181193 /// **Note**: Defaults to an empty HashSet.
@@ -351,27 +363,6 @@ impl Configuration {
351363 self
352364 }
353365
354- /// Whether the bot should respond to other bots.
355- ///
356- /// For example, if this is set to false, then the bot will respond to any other bots including
357- /// itself.
358- ///
359- /// **Note**: Defaults to `true`.
360- #[ must_use]
361- pub fn ignore_bots ( mut self , ignore_bots : bool ) -> Self {
362- self . ignore_bots = ignore_bots;
363- self
364- }
365-
366- /// If set to true, bot will ignore all commands called by webhooks.
367- ///
368- /// **Note**: Defaults to `true`.
369- #[ must_use]
370- pub fn ignore_webhooks ( mut self , ignore_webhooks : bool ) -> Self {
371- self . ignore_webhooks = ignore_webhooks;
372- self
373- }
374-
375366 /// Whether or not to respond to commands initiated with `id_to_mention`.
376367 ///
377368 /// **Note**: that this can be used in conjunction with [`Self::prefix`].
@@ -485,20 +476,6 @@ impl Configuration {
485476 self
486477 }
487478
488- /// Sets whether command execution can be done without a prefix. Works only in private channels.
489- ///
490- /// **Note**: Defaults to `false`.
491- ///
492- /// # Note
493- ///
494- /// The `cache` feature is required. If disabled this does absolutely nothing.
495- #[ inline]
496- #[ must_use]
497- pub fn no_dm_prefix ( mut self , b : bool ) -> Self {
498- self . no_dm_prefix = b;
499- self
500- }
501-
502479 /// Sets a single delimiter to be used when splitting the content after a command.
503480 ///
504481 /// **Note**: Defaults to a vector with a single element of `' '`.
@@ -555,7 +532,7 @@ impl Configuration {
555532 /// **Note**: Defaults to `false`.
556533 #[ must_use]
557534 pub fn case_insensitivity ( mut self , cs : bool ) -> Self {
558- self . case_insensitive = cs ;
535+ self = self . case_insensitive ( cs ) ;
559536
560537 for prefix in & mut self . prefixes {
561538 * prefix = prefix. to_lowercase ( ) ;
@@ -585,23 +562,20 @@ impl Default for Configuration {
585562 /// - **owners** to an empty HashSet
586563 /// - **prefix** to "~"
587564 fn default ( ) -> Configuration {
588- Configuration {
589- allow_dm : true ,
565+ let config = Configuration {
566+ __generated_flags : ConfigurationGeneratedFlags :: empty ( ) ,
590567 with_whitespace : WithWhiteSpace :: default ( ) ,
591- by_space : true ,
592568 blocked_guilds : HashSet :: default ( ) ,
593569 blocked_users : HashSet :: default ( ) ,
594570 allowed_channels : HashSet :: default ( ) ,
595- case_insensitive : false ,
596571 delimiters : vec ! [ Delimiter :: Single ( ' ' ) ] ,
597572 disabled_commands : HashSet :: default ( ) ,
598573 dynamic_prefixes : Vec :: new ( ) ,
599- ignore_bots : true ,
600- ignore_webhooks : true ,
601- no_dm_prefix : false ,
602574 on_mention : None ,
603575 owners : HashSet :: default ( ) ,
604576 prefixes : vec ! [ String :: from( "~" ) ] ,
605- }
577+ } ;
578+
579+ config. allow_dm ( true ) . by_space ( true ) . ignore_bots ( true ) . ignore_webhooks ( true )
606580 }
607581}
0 commit comments