-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBaseCommandInterface.ts
More file actions
69 lines (62 loc) · 1.99 KB
/
BaseCommandInterface.ts
File metadata and controls
69 lines (62 loc) · 1.99 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import {
AutocompleteInteraction,
ChatInputCommandInteraction,
Guild,
PermissionResolvable,
SlashCommandBuilder,
SlashCommandOptionsOnlyBuilder,
SlashCommandSubcommandBuilder,
SlashCommandSubcommandsOnlyBuilder,
} from 'discord.js';
import { Result } from 'neverthrow';
import { CommandError } from '#/utilities/error/def';
export interface AccessControl {
developer_only?: boolean;
bot_requires_permission?: PermissionResolvable[];
invoker_requires_permission?: PermissionResolvable[];
// The name of the option that might hold the channel / thread
channel_option_name?: string;
required_entitlement_sku?: string;
}
export enum RegistrationScope {
// For commands we want registered anywhere by default
GLOBAL,
// For command we only want to be registered on the dev server
DEVELOPMENT_SERVER,
// For command we dont want registered anywhere by default
NONE,
}
export interface GuildChatInteraction extends ChatInputCommandInteraction {
guild: Guild;
guildId: string;
}
export type CleanupFunction = (interaction: GuildChatInteraction) => void;
export interface PostExecutionTasks {
cleanup: {
func: CleanupFunction;
cleanup_timing?: number;
};
}
export interface BaseCommand {
command_data:
| Omit<SlashCommandBuilder, 'addSubcommandGroup' | 'addSubcommand'>
| SlashCommandSubcommandsOnlyBuilder
| SlashCommandOptionsOnlyBuilder
| SlashCommandSubcommandBuilder;
access_control: AccessControl;
command_scope: RegistrationScope;
}
export interface Command<TCommandCTX> extends BaseCommand {
run: (
interaction: GuildChatInteraction,
ctx: TCommandCTX,
) => Promise<Result<unknown, CommandError>> | Result<unknown, CommandError>;
autocomplete?: (
interaction: AutocompleteInteraction,
) => Result<unknown, CommandError> | Promise<Result<unknown, CommandError>>;
access_control: AccessControl;
command_scope: RegistrationScope;
}
export interface SubCommand<TCommandCTX> extends Command<TCommandCTX> {
parent_command: string;
}