From 048f99752550c6e03d1990a03cad78f3ac7d73aa Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 5 Sep 2022 17:36:42 -0400 Subject: revamp command permissions, fix permission exploit for some command when used in forum channels, use enums more --- src/inhibitors/command/disabledGuild.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/inhibitors/command/disabledGuild.ts (limited to 'src/inhibitors/command/disabledGuild.ts') diff --git a/src/inhibitors/command/disabledGuild.ts b/src/inhibitors/command/disabledGuild.ts new file mode 100644 index 0000000..0df827d --- /dev/null +++ b/src/inhibitors/command/disabledGuild.ts @@ -0,0 +1,25 @@ +import { BotInhibitor, InhibitorReason, InhibitorType, type BotCommand, type CommandMessage, type SlashMessage } from '#lib'; + +export default class DisabledGuildInhibitor extends BotInhibitor { + public constructor() { + super(InhibitorReason.DisabledGuild, { + reason: InhibitorReason.DisabledGuild, + type: InhibitorType.Post, + priority: 250 + }); + } + + public async exec(message: CommandMessage | SlashMessage, command: BotCommand): Promise { + if (!message.guild || !message.guild) return false; + if (message.author.isOwner() || message.author.isSuperUser()) return false; // super users bypass guild disabled commands + + if ((await message.guild.getSetting('disabledCommands'))?.includes(command?.id)) { + void this.client.console.verbose( + InhibitorReason.DisabledGuild, + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); + return true; + } + return false; + } +} -- cgit