diff options
Diffstat (limited to 'lib/extensions/discord-akairo/BotInhibitor.ts')
-rw-r--r-- | lib/extensions/discord-akairo/BotInhibitor.ts | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/extensions/discord-akairo/BotInhibitor.ts b/lib/extensions/discord-akairo/BotInhibitor.ts index d134eab..8892b8b 100644 --- a/lib/extensions/discord-akairo/BotInhibitor.ts +++ b/lib/extensions/discord-akairo/BotInhibitor.ts @@ -1,8 +1,12 @@ -import { type BotCommand, type CommandMessage, type SlashMessage } from '#lib'; -import { Inhibitor } from 'discord-akairo'; +import type { BotCommand, CommandMessage, InhibitorReason, InhibitorType, SlashMessage } from '#lib'; +import { Inhibitor, InhibitorOptions } from 'discord-akairo'; import { Message } from 'discord.js'; export abstract class BotInhibitor extends Inhibitor { + public constructor(id: InhibitorReason, options?: BotInhibitorOptions) { + super(id, options); + } + /** * Checks if message should be blocked. * A return value of true will block the message. @@ -16,3 +20,28 @@ export abstract class BotInhibitor extends Inhibitor { public abstract override exec(message: CommandMessage, command: BotCommand): any; public abstract override exec(message: CommandMessage | SlashMessage, command: BotCommand): any; } + +/** + * Options to use for inhibitor execution behavior. + */ +export interface BotInhibitorOptions extends InhibitorOptions { + /** + * Reason emitted when command or message is blocked. + * @default "" + */ + reason: InhibitorReason; + + /** + * - {@link InhibitorType.All} run on all messages + * - {@link InhibitorType.Pre} run on messages not blocked by the built-in inhibitors + * - {@link InhibitorType.Post} run on messages that are commands + */ + type: InhibitorType; + + /** + * Priority for the inhibitor for when more than one inhibitors block a message. + * The inhibitor with the highest priority is the one that is used for the block reason. + * @default 0 + */ + priority?: number; +} |