@@ -126,22 +126,12 @@ class GEventHandling {
126126 if ( inhibitReturn === false ) return ;
127127
128128 const cooldown = message . guild ? await this . client . dispatcher . getCooldown ( message . guild . id , message . author . id , commandos ) : null ;
129- const NSFW = message . guild ? commandos . nsfw && ! message . channel . nsfw : null ;
130- const isNotChannelType = type => channelType !== type ;
131- const isNotGuild = guild => ! commandos . guildOnly . includes ( guild ) ;
132-
133129 const getCooldownMessage = ( ) => this . client . languageFile . COOLDOWN [ language ] . replace ( / { C O O L D O W N } / g, cooldown . wait ) . replace ( / { C M D N A M E } / g, commandos . name ) ;
134- const getChannelTextOnlyMessage = ( ) => this . client . languageFile . CHANNEL_TEXT_ONLY [ language ] ;
135- const getChannelNewsOnlyMessage = ( ) => this . client . languageFile . CHANNEL_NEWS_ONLY [ language ] ;
136- const getChannelThreadOnlyMessage = ( ) => this . client . languageFile . CHANNEL_THREAD_ONLY [ language ] ;
137- const getNsfwMessage = ( ) => this . client . languageFile . NSFW [ language ] ;
138- const getMissingClientPermissionsMessage = ( ) => this . client . languageFile . MISSING_CLIENT_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . clientRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
139- const getMissingPermissionsMessage = ( ) => this . client . languageFile . MISSING_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . userRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
140- const getMissingRolesMessage = ( ) => this . client . languageFile . MISSING_ROLES [ language ] . replace ( '{ROLES}' , `\`${ commandos . userRequiredRoles . map ( r => message . guild . roles . cache . get ( r ) . name ) . join ( ', ' ) } \`` ) ;
141- const getArgsTimeLimitMessage = ( ) => this . client . languageFile . ARGS_TIME_LIMIT [ language ] ;
142130
143131 if ( cooldown ?. cooldown ) return message . reply ( getCooldownMessage ( ) ) ;
144132
133+ const isNotGuild = guild => ! commandos . guildOnly . includes ( guild ) ;
134+
145135 if ( isNotDm && commandos . guildOnly && isNotGuild ( message . guild . id ) ) return ;
146136
147137 if ( commandos . userOnly ) {
@@ -158,31 +148,47 @@ class GEventHandling {
158148 } else if ( message . channel . id !== commandos . channelOnly ) { return ; }
159149 }
160150
151+ const isNotChannelType = type => channelType !== type ;
152+ const getChannelTextOnlyMessage = ( ) => this . client . languageFile . CHANNEL_TEXT_ONLY [ language ] ;
153+ const getChannelNewsOnlyMessage = ( ) => this . client . languageFile . CHANNEL_NEWS_ONLY [ language ] ;
154+ const getChannelThreadOnlyMessage = ( ) => this . client . languageFile . CHANNEL_THREAD_ONLY [ language ] ;
155+
161156 if ( isNotDm && commandos . channelTextOnly && isNotChannelType ( 'text' ) ) return message . reply ( getChannelTextOnlyMessage ( ) ) ;
162157 if ( isNotDm && commandos . channelNewsOnly && isNotChannelType ( 'news' ) ) return message . reply ( getChannelNewsOnlyMessage ( ) ) ;
163158 if ( isNotDm && commandos . channelThreadOnly && isNotChannelType ( 'thread' ) ) return message . reply ( { content : getChannelThreadOnlyMessage ( ) , ephemeral : true } ) ;
164159
160+ const NSFW = message . guild ? commandos . nsfw && ! message . channel . nsfw : null ;
161+ const getNsfwMessage = ( ) => this . client . languageFile . NSFW [ language ] ;
162+
165163 if ( NSFW ) return message . reply ( getNsfwMessage ( ) ) ;
166164
165+ const getMissingClientPermissionsMessage = ( ) => this . client . languageFile . MISSING_CLIENT_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . clientRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
166+
167167 if ( isNotDm && commandos . clientRequiredPermissions ) {
168168 if ( ! Array . isArray ( commandos . clientRequiredPermissions ) ) commandos . clientRequiredPermissions = [ commandos . clientRequiredPermissions ] ;
169169
170170 if ( message . channel . permissionsFor ( message . guild . me ) . missing ( commandos . clientRequiredPermissions ) . length > 0 ) return message . reply ( getMissingClientPermissionsMessage ( ) ) ;
171171 }
172172
173+ const getMissingPermissionsMessage = ( ) => this . client . languageFile . MISSING_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . userRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
174+
173175 if ( isNotDm && commandos . userRequiredPermissions ) {
174176 if ( ! Array . isArray ( commandos . userRequiredPermissions ) ) commandos . userRequiredPermissions = [ commandos . userRequiredPermissions ] ;
175177
176178 if ( ! message . member . permissions . has ( commandos . userRequiredPermissions ) ) return message . reply ( getMissingPermissionsMessage ( ) ) ;
177179 }
178180
181+ const getMissingRolesMessage = ( ) => this . client . languageFile . MISSING_ROLES [ language ] . replace ( '{ROLES}' , `\`${ commandos . userRequiredRoles . map ( r => message . guild . roles . cache . get ( r ) . name ) . join ( ', ' ) } \`` ) ;
182+
179183 if ( isNotDm && commandos . userRequiredRoles ) {
180184 if ( ! Array . isArray ( commandos . userRequiredRoles ) ) commandos . userRequiredRoles = [ commandos . userRequiredRoles ] ;
181185
182186 const roles = commandos . userRequiredRoles . some ( v => message . member . _roles . includes ( v ) ) ;
183187 if ( ! roles ) return message . reply ( getMissingRolesMessage ( ) ) ;
184188 }
185189
190+ const getArgsTimeLimitMessage = ( ) => this . client . languageFile . ARGS_TIME_LIMIT [ language ] ;
191+
186192 let cmdArgs = commandos . args ? JSON . parse ( JSON . stringify ( commandos . args ) ) : [ ] ;
187193 const objectArgs = [ ] ;
188194 const finalArgs = [ ] ;
@@ -436,17 +442,7 @@ class GEventHandling {
436442 if ( inhibitReturn === false ) return ;
437443
438444 const cooldown = interaction . guild ? await this . client . dispatcher . getCooldown ( interaction . guild . id , interaction . author . id , commandos ) : null ;
439- const NSFW = interaction . guild ? commandos . nsfw && ! interaction . channel . nsfw : null ;
440- const isNotChannelType = type => channelType !== type ;
441-
442445 const getCooldownMessage = ( ) => this . client . languageFile . COOLDOWN [ language ] . replace ( / { C O O L D O W N } / g, cooldown . wait ) . replace ( / { C M D N A M E } / g, commandos . name ) ;
443- const getChannelTextOnlyMessage = ( ) => this . client . languageFile . CHANNEL_TEXT_ONLY [ language ] ;
444- const getChannelNewsOnlyMessage = ( ) => this . client . languageFile . CHANNEL_NEWS_ONLY [ language ] ;
445- const getChannelThreadOnlyMessage = ( ) => this . client . languageFile . CHANNEL_THREAD_ONLY [ language ] ;
446- const getNsfwMessage = ( ) => this . client . languageFile . NSFW [ language ] ;
447- const getMissingClientPermissionsMessage = ( ) => this . client . languageFile . MISSING_CLIENT_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . clientRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
448- const getMissingPermissionsMessage = ( ) => this . client . languageFile . MISSING_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . userRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
449- const getMissingRolesMessage = ( ) => this . client . languageFile . MISSING_ROLES [ language ] . replace ( '{ROLES}' , `\`${ commandos . userRequiredRoles . map ( r => interaction . guild . roles . cache . get ( r ) . name ) . join ( ', ' ) } \`` ) ;
450446
451447 if ( cooldown ?. cooldown ) return interaction . reply . send ( getCooldownMessage ( ) ) ;
452448
@@ -464,11 +460,22 @@ class GEventHandling {
464460 } else if ( interaction . channel . id !== commandos . channelOnly ) { return ; }
465461 }
466462
463+ const NSFW = interaction . guild ? commandos . nsfw && ! interaction . channel . nsfw : null ;
464+ const getNsfwMessage = ( ) => this . client . languageFile . NSFW [ language ] ;
465+
467466 if ( isNotDm && NSFW ) { return interaction . reply . send ( { content : getNsfwMessage ( ) , ephemeral : true } ) ; }
467+
468+ const isNotChannelType = type => channelType !== type ;
469+ const getChannelTextOnlyMessage = ( ) => this . client . languageFile . CHANNEL_TEXT_ONLY [ language ] ;
470+ const getChannelNewsOnlyMessage = ( ) => this . client . languageFile . CHANNEL_NEWS_ONLY [ language ] ;
471+ const getChannelThreadOnlyMessage = ( ) => this . client . languageFile . CHANNEL_THREAD_ONLY [ language ] ;
472+
468473 if ( isNotDm && commandos . channelTextOnly && isNotChannelType ( 'text' ) ) { return interaction . reply . send ( { content : getChannelTextOnlyMessage ( ) , ephemeral : true } ) ; }
469474 if ( isNotDm && commandos . channelNewsOnly && isNotChannelType ( 'news' ) ) { return interaction . reply . send ( { content : getChannelNewsOnlyMessage ( ) , ephemeral : true } ) ; }
470475 if ( isNotDm && commandos . channelThreadOnly && isNotChannelType ( 'thread' ) ) { return interaction . reply . send ( { content : getChannelThreadOnlyMessage ( ) , ephemeral : true } ) ; }
471476
477+ const getMissingClientPermissionsMessage = ( ) => this . client . languageFile . MISSING_CLIENT_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . clientRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
478+
472479 if ( isNotDm && commandos . clientRequiredPermissions ) {
473480 if ( ! Array . isArray ( commandos . clientRequiredPermissions ) ) commandos . clientRequiredPermissions = [ commandos . clientRequiredPermissions ] ;
474481
@@ -480,6 +487,8 @@ class GEventHandling {
480487 }
481488 }
482489
490+ const getMissingPermissionsMessage = ( ) => this . client . languageFile . MISSING_PERMISSIONS [ language ] . replace ( '{PERMISSION}' , commandos . userRequiredPermissions . map ( v => unescape ( v , '_' ) ) . join ( ', ' ) ) ;
491+
483492 if ( isNotDm && commandos . userRequiredPermissions ) {
484493 if ( ! Array . isArray ( commandos . userRequiredPermissions ) ) commandos . userRequiredPermissions = [ commandos . userRequiredPermissions ] ;
485494
@@ -491,6 +500,8 @@ class GEventHandling {
491500 }
492501 }
493502
503+ const getMissingRolesMessage = ( ) => this . client . languageFile . MISSING_ROLES [ language ] . replace ( '{ROLES}' , `\`${ commandos . userRequiredRoles . map ( r => interaction . guild . roles . cache . get ( r ) . name ) . join ( ', ' ) } \`` ) ;
504+
494505 if ( isNotDm && commandos . userRequiredRoles ) {
495506 if ( ! Array . isArray ( commandos . userRequiredRoles ) ) commandos . userRequiredRoles = [ commandos . userRequiredRoles ] ;
496507
0 commit comments