diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-09-05 17:36:42 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-09-05 17:36:42 -0400 |
commit | 048f99752550c6e03d1990a03cad78f3ac7d73aa (patch) | |
tree | c238ac29b1b526e86bcbc4989036df981c860187 /src/inhibitors/command/disabledGuild.ts | |
parent | 6f8a4d13a490eda7a195d14833c83810f7b5a789 (diff) | |
download | tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.tar.gz tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.tar.bz2 tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.zip |
revamp command permissions, fix permission exploit for some command when used in forum channels, use enums more
Diffstat (limited to 'src/inhibitors/command/disabledGuild.ts')
-rw-r--r-- | src/inhibitors/command/disabledGuild.ts | 25 |
1 files changed, 25 insertions, 0 deletions
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<boolean> { + 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; + } +} |