From 725a998e522f81e8b3372bcf7e647266202a550a Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Wed, 7 Aug 2024 14:46:39 +0300 Subject: [PATCH] feat(help): hide non-admin commands from non-admins --- src/commands/help.command.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commands/help.command.ts b/src/commands/help.command.ts index 62c50da..ee253b3 100644 --- a/src/commands/help.command.ts +++ b/src/commands/help.command.ts @@ -3,6 +3,7 @@ import { command, commands } from '@/core/commands' import { DEFAULT_COMMAND_PREFIX } from '@/env' import { logger } from '@/core/logger' import { isWhitelisted } from '@/lib/whitelist' +import { isAdministrator } from '@/utils/discord_utils' interface HelpMessage { command: string @@ -17,6 +18,7 @@ export default command({ global: true, async execute(message, args) { const whitelisted = await isWhitelisted('commands', message.guild!, message.channel) + const isAdmin = await isAdministrator(message.member!) let output = '' const data: HelpMessage[] = [] const name = args[0] @@ -28,7 +30,8 @@ export default command({ c.aliases.some((a) => a.toLowerCase() === name.toLowerCase()) : true const isGlobal = c.global ?? false - return [nameMatches, whitelisted || isGlobal].every(Boolean) + const isPermitted = !c.adminOnly || isAdmin + return [nameMatches, whitelisted || isGlobal, isPermitted].every(Boolean) }) for (const cmd of commandList) {