(client, guildId, commandName, context = {})
| 219 | } |
| 220 | |
| 221 | export async function disableCommand(client, guildId, commandName, context = {}) { |
| 222 | const normalizedName = String(commandName || '').toLowerCase().trim(); |
| 223 | const target = resolveCommandTarget(client, normalizedName); |
| 224 | |
| 225 | if (!target) { |
| 226 | throw new Error(`Unknown command: \`${normalizedName}\`.`); |
| 227 | } |
| 228 | |
| 229 | if (!target.isSubcommand && isProtectedCommand(normalizedName)) { |
| 230 | throw new Error(`The \`${normalizedName}\` command cannot be disabled.`); |
| 231 | } |
| 232 | |
| 233 | const config = await getGuildConfig(client, guildId, context); |
| 234 | const disabledCommands = normalizeToggleRecord(config?.disabledCommands); |
| 235 | disabledCommands[normalizedName] = true; |
| 236 | |
| 237 | await persistAccessConfig(client, guildId, { disabledCommands }, context); |
| 238 | return { commandName: normalizedName, enabled: false }; |
| 239 | } |
| 240 | |
| 241 | export async function enableCommand(client, guildId, commandName, context = {}) { |
| 242 | const normalizedName = String(commandName || '').toLowerCase().trim(); |
no test coverage detected