aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/BushCommand.ts
blob: 9de2c952bb99befd5ff428f60b956b6834ad3510 (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
48
49
50
51
52
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Command, CommandOptions } from 'discord-akairo';
import { APIApplicationCommandOption } from 'discord-api-types';
import { CommandInteraction, Snowflake } from 'discord.js';
import { BushClient } from './BushClient';
import { BushInteractionMessage } from './BushInteractionMessage';
import { BushMessage } from './BushMessage';

export interface BushCommandOptions extends CommandOptions {
	hidden?: boolean;
	restrictedChannels?: Snowflake[];
	restrictedGuilds?: Snowflake[];
	slashCommandOptions?: APIApplicationCommandOption[];
	description: {
		content: string;
		usage: string;
		examples: string[];
	};
}

export class BushCommand extends Command {
	public declare client: BushClient;
	public options: BushCommandOptions;
	/** The channels the command is limited to run in. */
	public restrictedChannels: Snowflake[];
	/** The guilds the command is limited to run in. */
	public restrictedGuilds: Snowflake[];
	/** Whether the command is hidden from the help command. */
	public hidden: boolean;
	constructor(id: string, options?: BushCommandOptions) {
		super(id, options);
		this.options = options;
		this.hidden = options.hidden || false;
		this.restrictedChannels = options.restrictedChannels;
		this.restrictedGuilds = options.restrictedGuilds;
	}

	public exec(message: BushMessage, args: any): any;
	// @ts-ignore: They are close enough
	public exec(message: BushMessage | BushInteractionMessage, args: any): any {
		// @ts-ignore: They are close enough
		super.exec(message, args);
	}

	/** Be careful when using this with a slash command since only the interaction is parsed as the message */
	public before(message: BushMessage): any;
	public before(message: BushMessage | CommandInteraction): any;
	public before(message) {
		super.before(message);
	}
}