diff options
Diffstat (limited to 'src/lib/extensions')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommandHandler.ts | 68 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushSlashMessage.ts | 5 |
2 files changed, 8 insertions, 65 deletions
diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 21984ab..44a0966 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -9,7 +9,6 @@ import { BushSlashMessage } from './BushSlashMessage'; export type BushCommandHandlerOptions = CommandHandlerOptions; const commandHandlerEvents = BushConstants.CommandHandlerEvents; -const blockedReasons = BushConstants.BlockedReasons; export interface BushCommandHandlerEvents extends CommandHandlerEvents { commandBlocked: [message: BushMessage, command: BushCommand, reason: string]; @@ -34,76 +33,17 @@ export class BushCommandHandler extends CommandHandler { super(client, options); } - // protected override setup(): void { - // super.setup(); - // } - public override async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise<boolean> { - if (command.ownerOnly) { - const isOwner = client.isOwner(message.author); - if (!isOwner) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.OWNER - ); - return true; - } - } - - if (command.superUserOnly) { - const isSuperUser = client.isSuperUser(message.author); - if (!isSuperUser) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.OWNER - ); - return true; - } - } - - if (command.channel === 'guild' && !message.guild) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.GUILD - ); + const reason = this.inhibitorHandler ? await this.inhibitorHandler.test('post', message, command) : null; + if (reason != null) { + this.emit(slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, message, command, reason); return true; } - if (command.channel === 'dm' && message.guild) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.DM - ); - return true; - } - if (command.restrictedChannels?.length && message.channel) { - if (!command.restrictedChannels.includes(message.channel.id)) { - this.emit(commandHandlerEvents.COMMAND_BLOCKED, message, command, blockedReasons.RESTRICTED_CHANNEL); - return true; - } - } - if (command.restrictedGuilds?.length && message.guild) { - if (!command.restrictedGuilds.includes(message.guild.id)) { - this.emit(commandHandlerEvents.COMMAND_BLOCKED, message, command, blockedReasons.RESTRICTED_GUILD); - return true; - } - } if (await this.runPermissionChecks(message, command)) { return true; } - const reason = this.inhibitorHandler ? await this.inhibitorHandler.test('post', message, command) : null; - if (reason != null) { - this.emit(commandHandlerEvents.COMMAND_BLOCKED, message, command, reason); - return true; - } + return !!this.runCooldowns(message, command); } } diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts index 215cf79..d10a024 100644 --- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts +++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts @@ -10,10 +10,13 @@ import { BushCommandUtil } from './BushCommandUtil'; export class BushSlashMessage extends AkairoMessage { public declare client: BushClient; public declare util: BushCommandUtil; - public declare guild: BushGuild; public declare author: BushUser; public declare member: BushGuildMember; public constructor(client: BushClient, interaction: CommandInteraction, command: BushCommand) { super(client, interaction, command); } + + public override get guild(): BushGuild | null { + return super.guild as BushGuild | null; + } } |