aboutsummaryrefslogtreecommitdiff
path: root/src/inhibitors/command/guildDisabledCommand.ts
blob: 97ac9958f2a841dfa33f2d6530dd6a96120a85a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { BotInhibitor, type BotCommand, type CommandMessage, type SlashMessage } from '#lib';

export default class DisabledGuildCommandInhibitor extends BotInhibitor {
	public constructor() {
		super('disabledGuildCommand', {
			reason: 'disabledGuild',
			type: '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(
				'disabledGuildCommand',
				`Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`
			);
			return true;
		}
		return false;
	}
}