(client, guildId, categoryKey, context = {})
| 255 | } |
| 256 | |
| 257 | export async function disableCategory(client, guildId, categoryKey, context = {}) { |
| 258 | const normalizedKey = normalizeCategoryKey(categoryKey); |
| 259 | const category = getCategoryRegistry(client, normalizedKey); |
| 260 | |
| 261 | if (!category) { |
| 262 | throw new Error(`Unknown category: \`${categoryKey}\`.`); |
| 263 | } |
| 264 | |
| 265 | const config = await getGuildConfig(client, guildId, context); |
| 266 | const disabledCategories = normalizeToggleRecord(config?.disabledCategories); |
| 267 | disabledCategories[normalizedKey] = true; |
| 268 | |
| 269 | await persistAccessConfig(client, guildId, { disabledCategories }, context); |
| 270 | return { categoryKey: normalizedKey, displayName: category.displayName, enabled: false }; |
| 271 | } |
| 272 | |
| 273 | export async function enableCategory(client, guildId, categoryKey, context = {}) { |
| 274 | const normalizedKey = normalizeCategoryKey(categoryKey); |
no test coverage detected