aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord-akairo/BushCommandHandler.ts
blob: 6c06c5bafa86c1fccba4e1760d5abec6e2c73c49 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { type BushClient, type BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { CommandHandler, type Category, type CommandHandlerEvents, type CommandHandlerOptions } from 'discord-akairo';
import { type Collection, type PermissionString } from 'discord.js';

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 {
	public declare client: BushClient;
	public declare modules: Collection<string, BushCommand>;
	public declare categories: Collection<string, Category<string, BushCommand>>;

	public constructor(client: BushClient, options: CommandHandlerOptions) {
		super(client, options);
	}
}

export interface BushCommandHandler extends CommandHandler {
	findCommand(name: string): BushCommand;
}