1+ //! General Configuration
2+
13use anyhow:: Result ;
24#[ cfg( feature = "config_file" ) ]
35use taplo:: dom:: Node ;
@@ -10,14 +12,20 @@ use crate::config::Node;
1012
1113#[ non_exhaustive]
1214pub ( super ) struct GeneralConfig {
15+ /// Discord token.
1316 token : String ,
17+ /// Prefix for commands.
1418 prefix : String ,
19+ /// Whether to auto register commands.
1520 auto_register_commands : bool ,
21+ /// Whether to auto change voice channel when user sended the command from
22+ /// another voice cahnnel.
1623 #[ cfg( feature = "music" ) ]
1724 vc_auto_change : bool ,
1825}
1926
2027impl GeneralConfig {
28+ /// Generate a new `GeneralConfig` from the config file.
2129 pub fn generate ( config_file : & Node ) -> Result < Self > {
2230 let token = get_value ! ( config_file, String , "BOT_TOKEN" , "general" =>"token" , "Discord token couldn't found." ) ?;
2331 let prefix = get_value ! ( config_file, String , "BOT_PREFIX" , "general" =>"prefix" , PREFIX ) ?;
@@ -34,12 +42,17 @@ impl GeneralConfig {
3442 } )
3543 }
3644
45+ /// Returns the Discord token.
3746 pub const fn token ( & self ) -> & String { & self . token }
3847
48+ /// Returns the prefix for commands.
3949 pub const fn prefix ( & self ) -> & String { & self . prefix }
4050
51+ /// Returns whether to auto register commands.
4152 pub const fn auto_register_commands ( & self ) -> bool { self . auto_register_commands }
4253
54+ /// Returns whether to auto change voice channel when user sended the
55+ /// command from another voice cahnnel.
4356 #[ cfg( feature = "music" ) ]
4457 pub const fn vc_auto_change ( & self ) -> bool { self . vc_auto_change }
4558}
0 commit comments