1
1
import { Command , CommandClient , Structures } from 'detritus-client' ;
2
2
import { ChannelTypes , Permissions } from 'detritus-client/lib/constants' ;
3
+ import { Markup } from 'detritus-client/lib/utils' ;
3
4
4
5
import { createGuildDisabledCommand , editGuildSettings } from '../../../api' ;
5
6
import { GuildSettings } from '../../../api/structures/guildsettings' ;
@@ -96,16 +97,17 @@ export default class CommandsDisable extends BaseCommand {
96
97
97
98
async run ( context : Command . Context , args : CommandArgs ) {
98
99
const { command } = args ;
100
+ const commandId = ( command . metadata && command . metadata . id ) ? command . metadata . id : command . name . split ( ' ' ) . join ( '.' ) ;
99
101
const guildId = context . guildId as string ;
100
102
101
103
const isServerWide = ! args . channels && ! args . roles && ! args . users ;
102
104
103
105
let settings = await GuildSettingsStore . getOrFetch ( context , guildId ) as GuildSettings ;
104
106
105
- let title = `Disabled ${ command . name } ` ;
107
+ let title = `Disabled ${ Markup . codestring ( commandId ) } ` ;
106
108
if ( isServerWide ) {
107
109
title = `${ title } server-wide` ;
108
- await createGuildDisabledCommand ( context , guildId , command . name , guildId , GuildDisableCommandsTypes . GUILD ) ;
110
+ await createGuildDisabledCommand ( context , guildId , commandId , guildId , GuildDisableCommandsTypes . GUILD ) ;
109
111
settings = await GuildSettingsStore . fetch ( context , guildId ) as GuildSettings ;
110
112
} else {
111
113
let channels = 0 , roles = 0 , users = 0 ;
@@ -131,7 +133,7 @@ export default class CommandsDisable extends BaseCommand {
131
133
}
132
134
133
135
for ( let payload of payloads ) {
134
- const key = `${ command . name } .${ payload . item . id } .${ payload . type } ` ;
136
+ const key = `${ commandId } .${ payload . item . id } .${ payload . type } ` ;
135
137
if ( ! settings . disabledCommands . has ( key ) ) {
136
138
await createGuildDisabledCommand ( context , guildId , command . name , payload . item . id , payload . type ) ;
137
139
}
0 commit comments