(config, commandName, category)
| 109 | } |
| 110 | |
| 111 | export function isCommandEnabledInConfig(config, commandName, category) { |
| 112 | const normalizedName = String(commandName || '').toLowerCase(); |
| 113 | |
| 114 | // Check if it's a subcommand (contains space) |
| 115 | const isSubcommand = normalizedName.includes(' '); |
| 116 | const baseCommand = isSubcommand ? normalizedName.split(' ')[0] : normalizedName; |
| 117 | |
| 118 | // Protected commands (only applies to base commands, not subcommands) |
| 119 | if (!isSubcommand && isProtectedCommand(baseCommand)) { |
| 120 | return true; |
| 121 | } |
| 122 | |
| 123 | const disabledCommands = normalizeToggleRecord(config?.disabledCommands); |
| 124 | const disabledCategories = normalizeToggleRecord(config?.disabledCategories); |
| 125 | |
| 126 | // Check if the specific command/subcommand is disabled |
| 127 | if (disabledCommands[normalizedName]) { |
| 128 | return false; |
| 129 | } |
| 130 | |
| 131 | // For subcommands, also check if the base command is disabled |
| 132 | if (isSubcommand && disabledCommands[baseCommand]) { |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | // Check if the category is disabled |
| 137 | if (disabledCategories[normalizeCategoryKey(category)]) { |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | return true; |
| 142 | } |
| 143 | |
| 144 | export async function isCommandEnabled(client, guildId, commandName, category = null) { |
| 145 | const config = await getGuildConfig(client, guildId); |
no test coverage detected