diff options
Diffstat (limited to 'src/lib/extensions/discord-akairo')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommand.ts | 29 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommandHandler.ts | 19 |
2 files changed, 36 insertions, 12 deletions
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 1c8ea5b..073221d 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -1,5 +1,5 @@ import { ArgumentOptions, ArgumentPromptOptions, ArgumentTypeCaster, Command, CommandOptions } from 'discord-akairo'; -import { Snowflake } from 'discord.js'; +import { PermissionResolvable, Snowflake } from 'discord.js'; import { BushMessage } from '../discord.js/BushMessage'; import { BushClient } from './BushClient'; import { BushCommandHandler } from './BushCommandHandler'; @@ -136,7 +136,9 @@ export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { customType?: ArgumentTypeCaster | (string | string[])[] | RegExp | string | null; } -export interface BushCommandOptions extends CommandOptions { +export type BushMissingPermissionSupplier = (message: BushMessage | BushSlashMessage) => Promise<any> | any; + +export interface BushCommandOptions extends Omit<CommandOptions, 'userPermissions' | 'clientPermissions'> { hidden?: boolean; restrictedChannels?: Snowflake[]; restrictedGuilds?: Snowflake[]; @@ -148,6 +150,9 @@ export interface BushCommandOptions extends CommandOptions { args?: BushArgumentOptions[] & CustomBushArgumentOptions[]; category: string; pseudo?: boolean; + bypassChannelBlacklist?: boolean; + clientPermissions?: PermissionResolvable | PermissionResolvable[] | BushMissingPermissionSupplier; + userPermissions?: PermissionResolvable | PermissionResolvable[] | BushMissingPermissionSupplier; } export class BushCommand extends Command { @@ -155,13 +160,14 @@ export class BushCommand extends Command { public declare handler: BushCommandHandler; + /** The command's options */ public options: BushCommandOptions; /** The channels the command is limited to run in. */ - public restrictedChannels: Snowflake[]; + public restrictedChannels: Snowflake[] | undefined; /** The guilds the command is limited to run in. */ - public restrictedGuilds: Snowflake[]; + public restrictedGuilds: Snowflake[] | undefined; /** Whether the command is hidden from the help command. */ public hidden: boolean; @@ -169,6 +175,9 @@ export class BushCommand extends Command { /** A fake command, completely hidden from the help command. */ public pseudo: boolean; + /** Allow this command to be run in channels that are blacklisted. */ + public bypassChannelBlacklist: boolean; + public constructor(id: string, options: BushCommandOptions) { if (options.args && typeof options.args !== 'function') { options.args.forEach((_, index: number) => { @@ -179,12 +188,14 @@ export class BushCommand extends Command { } }); } - super(id, options); + // incompatible options + super(id, options as any); this.options = options; - this.hidden = options.hidden ?? false; - this.restrictedChannels = options.restrictedChannels!; - this.restrictedGuilds = options.restrictedGuilds!; - this.pseudo = options.pseudo!; + this.hidden = Boolean(options.hidden); + this.restrictedChannels = options.restrictedChannels; + this.restrictedGuilds = options.restrictedGuilds; + this.pseudo = Boolean(options.pseudo); + this.bypassChannelBlacklist = Boolean(options.bypassChannelBlacklist); } public override exec(message: BushMessage, args: any): any; diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index f8dcd93..8ab47d8 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -9,17 +9,30 @@ export type BushCommandHandlerOptions = CommandHandlerOptions; export interface BushCommandHandlerEvents extends CommandHandlerEvents { commandBlocked: [message: BushMessage, command: BushCommand, reason: string]; - + commandBreakout: [message: BushMessage, command: BushCommand, breakMessage: BushMessage]; + commandCancelled: [message: BushMessage, command: BushCommand, retryMessage?: BushMessage]; + commandFinished: [message: BushMessage, command: BushCommand, args: any, returnValue: any]; + commandInvalid: [message: BushMessage, command: BushCommand]; + commandLocked: [message: BushMessage, command: BushCommand]; + commandStarted: [message: BushMessage, command: BushCommand, args: any]; + cooldown: [message: BushMessage | BushSlashMessage, command: BushCommand, remaining: number]; + error: [error: Error, message: BushMessage, command?: BushCommand]; + inPrompt: [message: BushMessage]; + load: [command: BushCommand, isReload: boolean]; + messageBlocked: [message: BushMessage | BushSlashMessage, reason: string]; + messageInvalid: [message: BushMessage]; missingPermissions: [message: BushMessage, command: BushCommand, type: 'client' | 'user', missing: Array<PermissionString>]; - + remove: [command: BushCommand]; slashBlocked: [message: BushSlashMessage, command: BushCommand, reason: string]; - + slashError: [error: Error, message: BushSlashMessage, command: BushCommand]; + slashFinished: [message: BushSlashMessage, command: BushCommand, args: any, returnValue: any]; slashMissingPermissions: [ message: BushSlashMessage, command: BushCommand, type: 'client' | 'user', missing: Array<PermissionString> ]; + slashStarted: [message: BushSlashMessage, command: BushCommand, args: any]; } export class BushCommandHandler extends CommandHandler { |