MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / disableCommand

Function disableCommand

src/services/commandAccessService.js:221–239  ·  view source on GitHub ↗
(client, guildId, commandName, context = {})

Source from the content-addressed store, hash-verified

219}
220
221export 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
241export async function enableCommand(client, guildId, commandName, context = {}) {
242 const normalizedName = String(commandName || '').toLowerCase().trim();

Callers 2

executeFunction · 0.90
handleDashboardComponentFunction · 0.90

Calls 5

getGuildConfigFunction · 0.90
resolveCommandTargetFunction · 0.85
isProtectedCommandFunction · 0.85
normalizeToggleRecordFunction · 0.85
persistAccessConfigFunction · 0.85

Tested by

no test coverage detected