diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-30 16:48:07 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-30 16:48:07 -0400 |
commit | 42d2e2bf01b5debd4ecf605297f925ad5da7deb3 (patch) | |
tree | daf6678542cd8735f9930086f7a1e76ae6884e4e /src/lib/extensions | |
parent | 4ad90b19851a0853287c45d326a28be535b1607f (diff) | |
download | tanzanite-42d2e2bf01b5debd4ecf605297f925ad5da7deb3.tar.gz tanzanite-42d2e2bf01b5debd4ecf605297f925ad5da7deb3.tar.bz2 tanzanite-42d2e2bf01b5debd4ecf605297f925ad5da7deb3.zip |
I did this 2 weeks ago idk what I did
Diffstat (limited to 'src/lib/extensions')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommand.ts | 29 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommandHandler.ts | 19 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushClientEvents.d.ts | 7 |
3 files changed, 42 insertions, 13 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 { diff --git a/src/lib/extensions/discord.js/BushClientEvents.d.ts b/src/lib/extensions/discord.js/BushClientEvents.d.ts index eb36153..2c9de89 100644 --- a/src/lib/extensions/discord.js/BushClientEvents.d.ts +++ b/src/lib/extensions/discord.js/BushClientEvents.d.ts @@ -233,7 +233,12 @@ export interface BushClientEvents extends ClientEvents { caseID: string, dmSuccess: boolean ]; - bushLevelUp: []; + bushLevelUpdate: [ + member: BushGuildMember, + oldLevel: number, + newLevel: number, + currentXp: number + ]; } type Setting = |