@@ -56,6 +56,8 @@ pub async fn run(
5656 interaction. command_text . as_str ( ) , & config
5757 ) . ok_or ( "Cannot find any action type matching command name" ) ?;
5858
59+ let moderation_config = & config. moderation . ok_or ( "This module is disabled" ) ?;
60+
5961 let target_member = get_target_member (
6062 & discord_http, guild_id, target_id
6163 ) . await . map_err ( Error :: from) ?;
@@ -100,7 +102,7 @@ pub async fn run(
100102 let mut roles = target_member
101103 . ok_or ( "You can mute only user server members (User left or didn't join this server)" ) ?
102104 . roles ;
103- roles. push ( config . moderation . mute_role . ok_or ( "There is no role for muted users set" ) ?) ;
105+ roles. push ( moderation_config . mute_role . ok_or ( "There is no role for muted users set" ) ?) ;
104106
105107 discord_http. update_guild_member ( config. guild_id , target_id)
106108 . roles ( & roles) . await . map_err ( Error :: from) ?;
@@ -149,8 +151,8 @@ pub async fn run(
149151 let result_case = context. mongodb . create_case (
150152 discord_http. to_owned ( ) , & context. redis , case,
151153 case_embed. to_owned ( ) ,
152- if config . moderation . dm_case { Some ( target_id) } else { None } ,
153- config . moderation . logs_channel
154+ if moderation_config . dm_case { Some ( target_id) } else { None } ,
155+ moderation_config . logs_channel
154156 ) . await . err ( ) ;
155157
156158 Ok ( ( InteractionResponseData {
@@ -179,7 +181,7 @@ fn command_to_action_type(command_name: &str, config: &GuildConfig) -> Option<Ca
179181 let action_type = match command_name {
180182 "warn" => CaseActionType :: Warn ,
181183 "timeout" | "mute" => {
182- match config. moderation . mute_mode {
184+ match config. moderation . as_ref ( ) ? . mute_mode {
183185 MuteMode :: Timeout => CaseActionType :: Timeout ,
184186 MuteMode :: Role => CaseActionType :: Mute ,
185187 MuteMode :: DependOnCommand => {
0 commit comments