reciple 6.0.0-dev.19 → 6.0.0-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +183 -183
  3. package/dist/lib/bin.mjs +65 -65
  4. package/dist/lib/esm.mjs +1 -1
  5. package/dist/lib/index.js +35 -35
  6. package/dist/lib/reciple/classes/RecipleClient.js +296 -296
  7. package/dist/lib/reciple/classes/RecipleConfig.js +106 -106
  8. package/dist/lib/reciple/classes/RecipleModule.js +94 -94
  9. package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +242 -242
  10. package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js +85 -85
  11. package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js +216 -216
  12. package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js +178 -172
  13. package/dist/lib/reciple/classes/managers/CommandCooldownManager.js +100 -100
  14. package/dist/lib/reciple/classes/managers/{ClientCommandManager.js → CommandManager.js} +59 -62
  15. package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +25 -25
  16. package/dist/lib/reciple/classes/managers/{ClientModuleManager.js → ModuleManager.js} +179 -183
  17. package/dist/lib/reciple/flags.js +31 -31
  18. package/dist/lib/reciple/permissions.js +30 -30
  19. package/dist/lib/reciple/types/builders.js +11 -11
  20. package/dist/lib/reciple/types/commands.js +15 -15
  21. package/dist/lib/reciple/types/paramOptions.js +2 -2
  22. package/dist/lib/reciple/util.js +68 -68
  23. package/dist/lib/reciple/version.js +47 -47
  24. package/dist/types/bin.d.mts +2 -2
  25. package/dist/types/esm.d.mts +1 -1
  26. package/dist/types/index.d.ts +19 -19
  27. package/dist/types/reciple/classes/RecipleClient.d.ts +103 -103
  28. package/dist/types/reciple/classes/RecipleConfig.d.ts +100 -100
  29. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -56
  30. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +150 -150
  31. package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +43 -43
  32. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +88 -88
  33. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +53 -51
  34. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +70 -70
  35. package/dist/types/reciple/classes/managers/{ClientCommandManager.d.ts → CommandManager.d.ts} +36 -37
  36. package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +22 -22
  37. package/dist/types/reciple/classes/managers/{ClientModuleManager.d.ts → ModuleManager.d.ts} +49 -49
  38. package/dist/types/reciple/flags.d.ts +17 -17
  39. package/dist/types/reciple/permissions.d.ts +19 -19
  40. package/dist/types/reciple/types/builders.d.ts +197 -197
  41. package/dist/types/reciple/types/commands.d.ts +81 -81
  42. package/dist/types/reciple/types/paramOptions.d.ts +101 -101
  43. package/dist/types/reciple/util.d.ts +23 -23
  44. package/dist/types/reciple/version.d.ts +25 -25
  45. package/package.json +1 -1
  46. package/resource/reciple.yml +120 -120
@@ -1,22 +1,22 @@
1
- import { MessageCommandValidatedOption } from '../builders/MessageCommandBuilder';
2
- import { RestOrArray } from 'discord.js';
3
- /**
4
- * Validated message options manager
5
- */
6
- export declare class MessageCommandOptionManager extends Array<MessageCommandValidatedOption> {
7
- constructor(...data: RestOrArray<MessageCommandValidatedOption>);
8
- /**
9
- * Get the option info
10
- * @param name Option name
11
- * @param requied Is the option required
12
- */
13
- get(name: string, requied: true): MessageCommandValidatedOption;
14
- get(name: string, requied?: boolean): MessageCommandValidatedOption | null;
15
- /**
16
- * Get the option value
17
- * @param name Option name
18
- * @param requied Is the option required
19
- */
20
- getValue(name: string, requied: true): string;
21
- getValue(name: string, requied?: boolean): string | null;
22
- }
1
+ import { MessageCommandValidatedOption } from '../builders/MessageCommandBuilder';
2
+ import { RestOrArray } from 'discord.js';
3
+ /**
4
+ * Validated message options manager
5
+ */
6
+ export declare class MessageCommandOptionManager extends Array<MessageCommandValidatedOption> {
7
+ constructor(...data: RestOrArray<MessageCommandValidatedOption>);
8
+ /**
9
+ * Get the option info
10
+ * @param name Option name
11
+ * @param requied Is the option required
12
+ */
13
+ get(name: string, requied: true): MessageCommandValidatedOption;
14
+ get(name: string, requied?: boolean): MessageCommandValidatedOption | null;
15
+ /**
16
+ * Get the option value
17
+ * @param name Option name
18
+ * @param requied Is the option required
19
+ */
20
+ getValue(name: string, requied: true): string;
21
+ getValue(name: string, requied?: boolean): string | null;
22
+ }
@@ -1,49 +1,49 @@
1
- import { Collection } from 'discord.js';
2
- import { ClientModuleManagerGetModulePathsOptions, ClientModuleManagerLoadModulesOptions, ClientModuleManagerResolveModuleFilesOptions, ClientModuleManagerStartModulesOptions, ClientModuleManagerUnloadModulesOptions } from '../../types/paramOptions';
3
- import { RecipleClient } from '../RecipleClient';
4
- import { RecipleModule, RecipleScript } from '../RecipleModule';
5
- export interface ClientModuleManagerOptions {
6
- client: RecipleClient;
7
- modules?: (RecipleModule | RecipleScript)[];
8
- }
9
- export declare class ClientModuleManager {
10
- readonly client: RecipleClient;
11
- readonly modules: Collection<string, RecipleModule>;
12
- constructor(options: ClientModuleManagerOptions);
13
- /**
14
- * Start modules
15
- * @param options start modules options
16
- * @returns started modules
17
- */
18
- startModules(options: ClientModuleManagerStartModulesOptions): Promise<RecipleModule[]>;
19
- /**
20
- * Load modules
21
- * @param options load modules options
22
- * @returns loaded modules
23
- */
24
- loadModules(options?: ClientModuleManagerLoadModulesOptions): Promise<RecipleModule[]>;
25
- /**
26
- * Unload modules
27
- * @param options unload modules options
28
- * @returns unloaded modules
29
- */
30
- unloadModules(options?: ClientModuleManagerUnloadModulesOptions): Promise<RecipleModule[]>;
31
- /**
32
- * Resolve modules from file paths
33
- * @param options resolve module files options
34
- * @returns resolved modules
35
- */
36
- resolveModuleFiles(options: ClientModuleManagerResolveModuleFilesOptions): Promise<RecipleModule[]>;
37
- /**
38
- * Validate module script
39
- * @param script module script
40
- * @returns `true` if script is valid
41
- */
42
- static validateScript(script: unknown): script is RecipleScript;
43
- /**
44
- * Get module file paths from folders
45
- * @param options get module paths options
46
- * @returns module paths
47
- */
48
- getModulePaths(options?: ClientModuleManagerGetModulePathsOptions): Promise<string[]>;
49
- }
1
+ import { Collection } from 'discord.js';
2
+ import { ModuleManagerGetModulePathsOptions, ModuleManagerLoadModulesOptions, ModuleManagerResolveModuleFilesOptions, ModuleManagerStartModulesOptions, ModuleManagerUnloadModulesOptions } from '../../types/paramOptions';
3
+ import { RecipleClient } from '../RecipleClient';
4
+ import { RecipleModule, RecipleScript } from '../RecipleModule';
5
+ export interface ModuleManagerOptions {
6
+ client: RecipleClient;
7
+ modules?: (RecipleModule | RecipleScript)[];
8
+ }
9
+ export declare class ModuleManager {
10
+ readonly client: RecipleClient;
11
+ readonly modules: Collection<string, RecipleModule>;
12
+ constructor(options: ModuleManagerOptions);
13
+ /**
14
+ * Start modules
15
+ * @param options start modules options
16
+ * @returns started modules
17
+ */
18
+ startModules(options: ModuleManagerStartModulesOptions): Promise<RecipleModule[]>;
19
+ /**
20
+ * Load modules
21
+ * @param options load modules options
22
+ * @returns loaded modules
23
+ */
24
+ loadModules(options?: ModuleManagerLoadModulesOptions): Promise<RecipleModule[]>;
25
+ /**
26
+ * Unload modules
27
+ * @param options unload modules options
28
+ * @returns unloaded modules
29
+ */
30
+ unloadModules(options?: ModuleManagerUnloadModulesOptions): Promise<RecipleModule[]>;
31
+ /**
32
+ * Resolve modules from file paths
33
+ * @param options resolve module files options
34
+ * @returns resolved modules
35
+ */
36
+ resolveModuleFiles(options: ModuleManagerResolveModuleFilesOptions): Promise<RecipleModule[]>;
37
+ /**
38
+ * Validate module script
39
+ * @param script module script
40
+ * @returns `true` if script is valid
41
+ */
42
+ static validateScript(script: unknown): script is RecipleScript;
43
+ /**
44
+ * Get module file paths from folders
45
+ * @param options get module paths options
46
+ * @returns module paths
47
+ */
48
+ getModulePaths(options?: ModuleManagerGetModulePathsOptions): Promise<string[]>;
49
+ }
@@ -1,17 +1,17 @@
1
- import { Command } from 'commander';
2
- /**
3
- * Commander
4
- */
5
- export declare const commander: Command;
6
- /**
7
- * Used flags
8
- */
9
- export declare const flags: import("commander").OptionValues;
10
- /**
11
- * Token flag
12
- */
13
- export declare const token: string | undefined;
14
- /**
15
- * Current working directory
16
- */
17
- export declare const cwd: string;
1
+ import { Command } from 'commander';
2
+ /**
3
+ * Commander
4
+ */
5
+ export declare const commander: Command;
6
+ /**
7
+ * Used flags
8
+ */
9
+ export declare const flags: import("commander").OptionValues;
10
+ /**
11
+ * Token flag
12
+ */
13
+ export declare const token: string | undefined;
14
+ /**
15
+ * Current working directory
16
+ */
17
+ export declare const cwd: string;
@@ -1,19 +1,19 @@
1
- import { Guild, GuildTextBasedChannel, PermissionResolvable } from 'discord.js';
2
- import { UserHasCommandPermissionsOptions } from './types/paramOptions';
3
- /**
4
- * Check if the user has permissions to execute the given command name
5
- * @param options options
6
- */
7
- export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
8
- /**
9
- * Check if the bot has the required permissions in a guild
10
- * @param guild Check if the bot has the required permissions in this guild
11
- * @param requiredPermissions Required guild bot permissions
12
- */
13
- export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
14
- /**
15
- * Check if the bot has the required permissions in a channel
16
- * @param channel Check if the bot has the required permissions in this channel
17
- * @param requiredPermissions Required guild bot permissions
18
- */
19
- export declare function botHasExecutePermissions(channel?: GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
1
+ import { Guild, GuildTextBasedChannel, PermissionResolvable } from 'discord.js';
2
+ import { UserHasCommandPermissionsOptions } from './types/paramOptions';
3
+ /**
4
+ * Check if the user has permissions to execute the given command name
5
+ * @param options options
6
+ */
7
+ export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
8
+ /**
9
+ * Check if the bot has the required permissions in a guild
10
+ * @param guild Check if the bot has the required permissions in this guild
11
+ * @param requiredPermissions Required guild bot permissions
12
+ */
13
+ export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
14
+ /**
15
+ * Check if the bot has the required permissions in a channel
16
+ * @param channel Check if the bot has the required permissions in this channel
17
+ * @param requiredPermissions Required guild bot permissions
18
+ */
19
+ export declare function botHasExecutePermissions(channel?: GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
@@ -1,197 +1,197 @@
1
- import { ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionType, Awaitable, LocalizationMap, PermissionResolvable, RestOrArray, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandUserOption } from 'discord.js';
2
- import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder } from '../classes/builders/SlashCommandBuilder';
3
- import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandExecuteFunction, MessageCommandHaltData, MessageCommandHaltFunction } from '../classes/builders/MessageCommandBuilder';
4
- import { MessageCommandOptionBuilder } from '../classes/builders/MessageCommandOptionBuilder';
5
- /**
6
- * Any command builders
7
- */
8
- export declare type AnyCommandBuilder<T = unknown> = AnySlashCommandBuilder<T> | MessageCommandBuilder<T>;
9
- /**
10
- * Any command data
11
- */
12
- export declare type AnyCommandData<T = unknown> = SlashCommandData<T> | MessageCommandData<T>;
13
- /**
14
- * Any slash command builders
15
- */
16
- export declare type AnySlashCommandBuilder<T = unknown> = SlashCommandBuilder<T> | SlashCommandOptionsOnlyBuilder<T> | SlashCommandSubcommandsOnlyBuilder<T>;
17
- /**
18
- * Any command halt functions
19
- */
20
- export declare type AnyCommandHaltFunction<T = unknown> = SlashCommandHaltFunction<T> | MessageCommandHaltFunction<T>;
21
- /**
22
- * Any command execute function
23
- */
24
- export declare type AnyCommandExecuteFunction<T = unknown> = SlashCommandExecuteFunction<T> | MessageCommandExecuteFunction<T>;
25
- /**
26
- * Command halt function
27
- */
28
- export declare type CommandHaltFunction<T extends CommandType, M = unknown> = (haltData: T extends CommandType.SlashCommand ? SlashCommandHaltData<M> : T extends CommandType.MessageCommand ? MessageCommandHaltData<M> : SlashCommandHaltData<M> | MessageCommandHaltData<M>) => Awaitable<boolean | null | undefined | void>;
29
- /**
30
- * Command execute function
31
- */
32
- export declare type CommandExecuteFunction<T extends CommandType, M = unknown> = (executeData: T extends CommandType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandType.MessageCommand ? MessageCommandExecuteData<M> : SlashCommandExecuteData<M> | MessageCommandExecuteData<M>) => Awaitable<void>;
33
- /**
34
- * Message command options resolvable
35
- */
36
- export declare type MessageCommandOptionResolvable = MessageCommandOptionBuilder | MessageCommandOptionData;
37
- /**
38
- * Slash command options
39
- */
40
- export declare type AnySlashCommandOptionData = AnySlashCommandOptionsOnlyOptionData | SlashCommandSubCommandGroupData | SlashCommandSubCommandData;
41
- /**
42
- * Slash command options builders
43
- */
44
- export declare type AnySlashCommandOptionBuilder = AnySlashCommandOptionsOnlyOptionBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandBuilder;
45
- /**
46
- * Slash command options without sub commands
47
- */
48
- export declare type AnySlashCommandOptionsOnlyOptionData = SlashCommandAttachmentOptionData | SlashCommandBooleanOptionData | SlashCommandChannelOptionData | SlashCommandIntegerOptionData | SlashCommandMentionableOptionData | SlashCommandNumberOptionData | SlashCommandRoleOptionData | SlashCommandStringOptionData | SlashCommandUserOptionData;
49
- /**
50
- * Slash command option builder without sub commands
51
- */
52
- export declare type AnySlashCommandOptionsOnlyOptionBuilder = SlashCommandAttachmentOption | SlashCommandBooleanOption | SlashCommandChannelOption | SlashCommandIntegerOption | SlashCommandMentionableOption | SlashCommandNumberOption | SlashCommandRoleOption | SlashCommandStringOption | SlashCommandUserOption;
53
- /**
54
- * Types of command builders
55
- */
56
- export declare enum CommandType {
57
- SlashCommand = 1,
58
- MessageCommand = 2
59
- }
60
- /**
61
- * Shared command builder methods and properties
62
- */
63
- export interface SharedCommandBuilderProperties<T = unknown> {
64
- readonly type: CommandType;
65
- cooldown: number;
66
- requiredBotPermissions: PermissionResolvable[];
67
- requiredMemberPermissions: PermissionResolvable[];
68
- halt?: AnyCommandHaltFunction<T>;
69
- execute: AnyCommandExecuteFunction<T>;
70
- metadata?: T;
71
- /**
72
- * Sets the execute cooldown for this command.
73
- * - `0` means no cooldown
74
- * @param cooldown Command cooldown in milliseconds
75
- */
76
- setCooldown(cooldown: number): this;
77
- /**
78
- * Set required bot permissions to execute the command
79
- * @param permissions Bot's required permissions
80
- */
81
- setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
82
- /**
83
- * Set required permissions to execute the command
84
- * @param permissions User's return permissions
85
- */
86
- setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
87
- /**
88
- * Function when the command is interupted
89
- * @param halt Function to execute when command is halted
90
- */
91
- setHalt(halt?: this['halt']): this;
92
- /**
93
- * Function when the command is executed
94
- * @param execute Function to execute when the command is called
95
- */
96
- setExecute(execute: this['execute']): this;
97
- /**
98
- * Set a command metadata
99
- * @param metadata Command metadata
100
- */
101
- setMetadata(metadata?: T): this;
102
- }
103
- /**
104
- * Shared command name and description properties
105
- */
106
- export interface SharedCommandDataProperties {
107
- name: string;
108
- description: string;
109
- }
110
- /**
111
- * Slash command object data interface
112
- */
113
- export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
114
- type: CommandType.SlashCommand;
115
- nameLocalizations?: LocalizationMap;
116
- descriptionLocalizations?: LocalizationMap;
117
- options?: (AnySlashCommandOptionData | AnySlashCommandOptionBuilder)[];
118
- /**
119
- * @deprecated This property is deprecated and will be removed in the future.
120
- */
121
- defaultPermission?: boolean;
122
- defaultMemberPermissions?: string | null;
123
- dmPermission?: boolean;
124
- halt?: SlashCommandHaltFunction<T>;
125
- execute: SlashCommandExecuteFunction<T>;
126
- }
127
- export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
128
- choices?: {
129
- name: string;
130
- nameLocalizations?: LocalizationMap;
131
- value: V;
132
- }[];
133
- autocomplete?: boolean;
134
- required?: boolean;
135
- }
136
- export interface SlashCommandAttachmentOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
137
- type: ApplicationCommandOptionType.Attachment;
138
- }
139
- export interface SlashCommandBooleanOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
140
- type: ApplicationCommandOptionType.Boolean;
141
- }
142
- export interface SlashCommandChannelOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
143
- type: ApplicationCommandOptionType.Channel;
144
- channelTypes?: ApplicationCommandOptionAllowedChannelTypes[];
145
- }
146
- export interface SlashCommandIntegerOptionData extends SharedSlashCommandOptionData<number> {
147
- type: ApplicationCommandOptionType.Integer;
148
- minValue?: number;
149
- maxValue?: number;
150
- }
151
- export interface SlashCommandMentionableOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
152
- type: ApplicationCommandOptionType.Mentionable;
153
- }
154
- export interface SlashCommandNumberOptionData extends SharedSlashCommandOptionData<number> {
155
- type: ApplicationCommandOptionType.Number;
156
- minValue?: number;
157
- maxValue?: number;
158
- }
159
- export interface SlashCommandRoleOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
160
- type: ApplicationCommandOptionType.Role;
161
- }
162
- export interface SlashCommandStringOptionData extends SharedSlashCommandOptionData<string> {
163
- type: ApplicationCommandOptionType.String;
164
- minLength?: number;
165
- maxLength?: number;
166
- }
167
- export interface SlashCommandUserOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
168
- type: ApplicationCommandOptionType.User;
169
- }
170
- export interface SlashCommandSubCommandData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
171
- type: ApplicationCommandOptionType.Subcommand;
172
- options: (AnySlashCommandOptionsOnlyOptionData | AnySlashCommandOptionsOnlyOptionBuilder)[];
173
- }
174
- export interface SlashCommandSubCommandGroupData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
175
- type: ApplicationCommandOptionType.SubcommandGroup;
176
- options: (SlashCommandSubCommandData | SlashCommandSubcommandBuilder)[];
177
- }
178
- /**
179
- * Message command object data interface
180
- */
181
- export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
182
- type: CommandType.MessageCommand;
183
- aliases?: string[];
184
- validateOptions?: boolean;
185
- allowExecuteInDM?: boolean;
186
- allowExecuteByBots?: boolean;
187
- halt?: MessageCommandHaltFunction<T>;
188
- execute: MessageCommandExecuteFunction<T>;
189
- options?: MessageCommandOptionResolvable[];
190
- }
191
- /**
192
- * Message command option object data interface
193
- */
194
- export interface MessageCommandOptionData extends SharedCommandDataProperties {
195
- required?: boolean;
196
- validator?: (value: string) => Awaitable<boolean>;
197
- }
1
+ import { ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionType, Awaitable, LocalizationMap, PermissionResolvable, RestOrArray, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandUserOption } from 'discord.js';
2
+ import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder } from '../classes/builders/SlashCommandBuilder';
3
+ import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandExecuteFunction, MessageCommandHaltData, MessageCommandHaltFunction } from '../classes/builders/MessageCommandBuilder';
4
+ import { MessageCommandOptionBuilder } from '../classes/builders/MessageCommandOptionBuilder';
5
+ /**
6
+ * Any command builders
7
+ */
8
+ export declare type AnyCommandBuilder<T = unknown> = AnySlashCommandBuilder<T> | MessageCommandBuilder<T>;
9
+ /**
10
+ * Any command data
11
+ */
12
+ export declare type AnyCommandData<T = unknown> = SlashCommandData<T> | MessageCommandData<T>;
13
+ /**
14
+ * Any slash command builders
15
+ */
16
+ export declare type AnySlashCommandBuilder<T = unknown> = SlashCommandBuilder<T> | SlashCommandOptionsOnlyBuilder<T> | SlashCommandSubcommandsOnlyBuilder<T>;
17
+ /**
18
+ * Any command halt functions
19
+ */
20
+ export declare type AnyCommandHaltFunction<T = unknown> = SlashCommandHaltFunction<T> | MessageCommandHaltFunction<T>;
21
+ /**
22
+ * Any command execute function
23
+ */
24
+ export declare type AnyCommandExecuteFunction<T = unknown> = SlashCommandExecuteFunction<T> | MessageCommandExecuteFunction<T>;
25
+ /**
26
+ * Command halt function
27
+ */
28
+ export declare type CommandHaltFunction<T extends CommandType, M = unknown> = (haltData: T extends CommandType.SlashCommand ? SlashCommandHaltData<M> : T extends CommandType.MessageCommand ? MessageCommandHaltData<M> : SlashCommandHaltData<M> | MessageCommandHaltData<M>) => Awaitable<boolean | null | undefined | void>;
29
+ /**
30
+ * Command execute function
31
+ */
32
+ export declare type CommandExecuteFunction<T extends CommandType, M = unknown> = (executeData: T extends CommandType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandType.MessageCommand ? MessageCommandExecuteData<M> : SlashCommandExecuteData<M> | MessageCommandExecuteData<M>) => Awaitable<void>;
33
+ /**
34
+ * Message command options resolvable
35
+ */
36
+ export declare type MessageCommandOptionResolvable = MessageCommandOptionBuilder | MessageCommandOptionData;
37
+ /**
38
+ * Slash command options
39
+ */
40
+ export declare type AnySlashCommandOptionData = AnySlashCommandOptionsOnlyOptionData | SlashCommandSubCommandGroupData | SlashCommandSubCommandData;
41
+ /**
42
+ * Slash command options builders
43
+ */
44
+ export declare type AnySlashCommandOptionBuilder = AnySlashCommandOptionsOnlyOptionBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandBuilder;
45
+ /**
46
+ * Slash command options without sub commands
47
+ */
48
+ export declare type AnySlashCommandOptionsOnlyOptionData = SlashCommandAttachmentOptionData | SlashCommandBooleanOptionData | SlashCommandChannelOptionData | SlashCommandIntegerOptionData | SlashCommandMentionableOptionData | SlashCommandNumberOptionData | SlashCommandRoleOptionData | SlashCommandStringOptionData | SlashCommandUserOptionData;
49
+ /**
50
+ * Slash command option builder without sub commands
51
+ */
52
+ export declare type AnySlashCommandOptionsOnlyOptionBuilder = SlashCommandAttachmentOption | SlashCommandBooleanOption | SlashCommandChannelOption | SlashCommandIntegerOption | SlashCommandMentionableOption | SlashCommandNumberOption | SlashCommandRoleOption | SlashCommandStringOption | SlashCommandUserOption;
53
+ /**
54
+ * Types of command builders
55
+ */
56
+ export declare enum CommandType {
57
+ SlashCommand = 1,
58
+ MessageCommand = 2
59
+ }
60
+ /**
61
+ * Shared command builder methods and properties
62
+ */
63
+ export interface SharedCommandBuilderProperties<T = unknown> {
64
+ readonly type: CommandType;
65
+ cooldown: number;
66
+ requiredBotPermissions: PermissionResolvable[];
67
+ requiredMemberPermissions: PermissionResolvable[];
68
+ halt?: AnyCommandHaltFunction<T>;
69
+ execute: AnyCommandExecuteFunction<T>;
70
+ metadata?: T;
71
+ /**
72
+ * Sets the execute cooldown for this command.
73
+ * - `0` means no cooldown
74
+ * @param cooldown Command cooldown in milliseconds
75
+ */
76
+ setCooldown(cooldown: number): this;
77
+ /**
78
+ * Set required bot permissions to execute the command
79
+ * @param permissions Bot's required permissions
80
+ */
81
+ setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
82
+ /**
83
+ * Set required permissions to execute the command
84
+ * @param permissions User's return permissions
85
+ */
86
+ setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
87
+ /**
88
+ * Function when the command is interupted
89
+ * @param halt Function to execute when command is halted
90
+ */
91
+ setHalt(halt?: this['halt']): this;
92
+ /**
93
+ * Function when the command is executed
94
+ * @param execute Function to execute when the command is called
95
+ */
96
+ setExecute(execute: this['execute']): this;
97
+ /**
98
+ * Set a command metadata
99
+ * @param metadata Command metadata
100
+ */
101
+ setMetadata(metadata?: T): this;
102
+ }
103
+ /**
104
+ * Shared command name and description properties
105
+ */
106
+ export interface SharedCommandDataProperties {
107
+ name: string;
108
+ description: string;
109
+ }
110
+ /**
111
+ * Slash command object data interface
112
+ */
113
+ export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
114
+ type: CommandType.SlashCommand;
115
+ nameLocalizations?: LocalizationMap;
116
+ descriptionLocalizations?: LocalizationMap;
117
+ options?: (AnySlashCommandOptionData | AnySlashCommandOptionBuilder)[];
118
+ /**
119
+ * @deprecated This property is deprecated and will be removed in the future.
120
+ */
121
+ defaultPermission?: boolean;
122
+ defaultMemberPermissions?: string | null;
123
+ dmPermission?: boolean;
124
+ halt?: SlashCommandHaltFunction<T>;
125
+ execute: SlashCommandExecuteFunction<T>;
126
+ }
127
+ export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
128
+ choices?: {
129
+ name: string;
130
+ nameLocalizations?: LocalizationMap;
131
+ value: V;
132
+ }[];
133
+ autocomplete?: boolean;
134
+ required?: boolean;
135
+ }
136
+ export interface SlashCommandAttachmentOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
137
+ type: ApplicationCommandOptionType.Attachment;
138
+ }
139
+ export interface SlashCommandBooleanOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
140
+ type: ApplicationCommandOptionType.Boolean;
141
+ }
142
+ export interface SlashCommandChannelOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
143
+ type: ApplicationCommandOptionType.Channel;
144
+ channelTypes?: ApplicationCommandOptionAllowedChannelTypes[];
145
+ }
146
+ export interface SlashCommandIntegerOptionData extends SharedSlashCommandOptionData<number> {
147
+ type: ApplicationCommandOptionType.Integer;
148
+ minValue?: number;
149
+ maxValue?: number;
150
+ }
151
+ export interface SlashCommandMentionableOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
152
+ type: ApplicationCommandOptionType.Mentionable;
153
+ }
154
+ export interface SlashCommandNumberOptionData extends SharedSlashCommandOptionData<number> {
155
+ type: ApplicationCommandOptionType.Number;
156
+ minValue?: number;
157
+ maxValue?: number;
158
+ }
159
+ export interface SlashCommandRoleOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
160
+ type: ApplicationCommandOptionType.Role;
161
+ }
162
+ export interface SlashCommandStringOptionData extends SharedSlashCommandOptionData<string> {
163
+ type: ApplicationCommandOptionType.String;
164
+ minLength?: number;
165
+ maxLength?: number;
166
+ }
167
+ export interface SlashCommandUserOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
168
+ type: ApplicationCommandOptionType.User;
169
+ }
170
+ export interface SlashCommandSubCommandData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
171
+ type: ApplicationCommandOptionType.Subcommand;
172
+ options: (AnySlashCommandOptionsOnlyOptionData | AnySlashCommandOptionsOnlyOptionBuilder)[];
173
+ }
174
+ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
175
+ type: ApplicationCommandOptionType.SubcommandGroup;
176
+ options: (SlashCommandSubCommandData | SlashCommandSubcommandBuilder)[];
177
+ }
178
+ /**
179
+ * Message command object data interface
180
+ */
181
+ export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
182
+ type: CommandType.MessageCommand;
183
+ aliases?: string[];
184
+ validateOptions?: boolean;
185
+ allowExecuteInDM?: boolean;
186
+ allowExecuteByBots?: boolean;
187
+ halt?: MessageCommandHaltFunction<T>;
188
+ execute: MessageCommandExecuteFunction<T>;
189
+ options?: MessageCommandOptionResolvable[];
190
+ }
191
+ /**
192
+ * Message command option object data interface
193
+ */
194
+ export interface MessageCommandOptionData extends SharedCommandDataProperties {
195
+ required?: boolean;
196
+ validator?: (value: string) => Awaitable<boolean>;
197
+ }