reciple 5.6.0 → 6.0.0-dev.10

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 (37) hide show
  1. package/dist/cjs/bin.js +13 -10
  2. package/dist/cjs/index.js +8 -7
  3. package/dist/cjs/reciple/classes/RecipleClient.js +90 -184
  4. package/dist/cjs/reciple/classes/RecipleConfig.js +9 -2
  5. package/dist/cjs/reciple/classes/RecipleModule.js +94 -0
  6. package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +7 -5
  7. package/dist/cjs/reciple/classes/builders/SlashCommandBuilder.js +12 -23
  8. package/dist/cjs/reciple/classes/managers/ApplicationCommandManager.js +136 -0
  9. package/dist/cjs/reciple/classes/managers/ClientCommandManager.js +62 -0
  10. package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +167 -0
  11. package/dist/cjs/reciple/classes/{CommandCooldownManager.js → managers/CommandCooldownManager.js} +15 -6
  12. package/dist/cjs/reciple/classes/{MessageCommandOptionManager.js → managers/MessageCommandOptionManager.js} +0 -0
  13. package/dist/cjs/reciple/permissions.js +3 -4
  14. package/dist/cjs/reciple/types/builders.js +6 -6
  15. package/dist/cjs/reciple/util.js +44 -1
  16. package/dist/types/index.d.ts +8 -7
  17. package/dist/types/reciple/classes/RecipleClient.d.ts +17 -65
  18. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -0
  19. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +7 -7
  20. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +17 -17
  21. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +15 -0
  22. package/dist/types/reciple/classes/managers/ClientCommandManager.d.ts +37 -0
  23. package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +19 -0
  24. package/dist/types/reciple/classes/{CommandCooldownManager.d.ts → managers/CommandCooldownManager.d.ts} +4 -3
  25. package/dist/types/reciple/classes/{MessageCommandOptionManager.d.ts → managers/MessageCommandOptionManager.d.ts} +1 -1
  26. package/dist/types/reciple/types/builders.d.ts +19 -19
  27. package/dist/types/reciple/types/commands.d.ts +12 -12
  28. package/dist/types/reciple/types/paramOptions.d.ts +6 -32
  29. package/dist/types/reciple/util.d.ts +10 -0
  30. package/package.json +30 -24
  31. package/dist/cjs/reciple/logger.js +0 -35
  32. package/dist/cjs/reciple/modules.js +0 -113
  33. package/dist/cjs/reciple/registerApplicationCommands.js +0 -49
  34. package/dist/types/reciple/logger.d.ts +0 -8
  35. package/dist/types/reciple/modules.d.ts +0 -64
  36. package/dist/types/reciple/registerApplicationCommands.d.ts +0 -9
  37. package/docs/README.md +0 -1
@@ -1,33 +1,19 @@
1
1
  import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandHaltData } from './builders/MessageCommandBuilder';
2
+ import { Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
2
3
  import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandHaltData } from './builders/SlashCommandBuilder';
3
- import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandBuilderType } from '../types/builders';
4
- import { ApplicationCommandBuilder } from '../registerApplicationCommands';
5
4
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
6
- import { CommandCooldownManager } from './CommandCooldownManager';
7
- import { RecipleClientAddModuleOptions } from '../types/paramOptions';
5
+ import { CommandCooldownManager } from './managers/CommandCooldownManager';
6
+ import { ApplicationCommandManager } from './managers/ApplicationCommandManager';
7
+ import { ClientCommandManager } from './managers/ClientCommandManager';
8
+ import { ClientModuleManager } from './managers/ClientModuleManager';
8
9
  import { Config } from './RecipleConfig';
9
- import { RecipleModule } from '../modules';
10
10
  import { Logger } from 'fallout-utility';
11
- import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Collection, Interaction, Message, RestOrArray } from 'discord.js';
12
11
  /**
13
12
  * Options for {@link RecipleClient}
14
13
  */
15
14
  export interface RecipleClientOptions extends ClientOptions {
16
15
  config?: Config;
17
16
  }
18
- /**
19
- * Reciple client commands
20
- */
21
- export interface RecipleClientCommands {
22
- /**
23
- * Collection of loaded slash commands
24
- */
25
- slashCommands: Collection<string, AnySlashCommandBuilder>;
26
- /**
27
- * Collection of loaded message commands
28
- */
29
- messageCommands: Collection<string, MessageCommandBuilder>;
30
- }
31
17
  /**
32
18
  * Reciple client events
33
19
  */
@@ -54,37 +40,18 @@ export interface RecipleClient<Ready extends boolean = boolean> extends Client<R
54
40
  isReady(): this is RecipleClient<true>;
55
41
  }
56
42
  export declare class RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
57
- config: Config;
58
- commands: RecipleClientCommands;
59
- additionalApplicationCommands: (ApplicationCommandBuilder | ApplicationCommandData)[];
60
- cooldowns: CommandCooldownManager;
61
- modules: RecipleModule[];
62
- logger: Logger;
63
- version: string;
43
+ readonly config: Config;
44
+ readonly commands: ClientCommandManager;
45
+ readonly applicationCommands: ApplicationCommandManager;
46
+ readonly cooldowns: CommandCooldownManager;
47
+ readonly modules: ClientModuleManager;
48
+ readonly logger: Logger;
49
+ readonly version: string;
50
+ get isClientLogsSilent(): boolean;
64
51
  /**
65
52
  * @param options Client options
66
53
  */
67
54
  constructor(options: RecipleClientOptions);
68
- /**
69
- * Load and start modules from given folders
70
- * @param folders folders that contains the modules you want to load
71
- */
72
- startModules(...folders: RestOrArray<string>): Promise<this>;
73
- /**
74
- * Execute {@link RecipleModule['onLoad']} from client modules and register application commands if enabled
75
- */
76
- loadModules(): Promise<this>;
77
- /**
78
- * Add module
79
- * @param options Module options
80
- * @deprecated This is very stupid, Just add it manually
81
- */
82
- addModule(options: RecipleClientAddModuleOptions): Promise<void>;
83
- /**
84
- * Add slash or message command to client
85
- * @param command Slash/Message command builder
86
- */
87
- addCommand(command: AnyCommandData | AnyCommandBuilder): RecipleClient<Ready>;
88
55
  /**
89
56
  * Listed to command executions
90
57
  */
@@ -93,34 +60,19 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
93
60
  * Execute a slash command
94
61
  * @param interaction Slash command interaction
95
62
  */
96
- slashCommandExecute(interaction: Interaction | ChatInputCommandInteraction): Promise<void | SlashCommandExecuteData>;
63
+ slashCommandExecute(interaction: Interaction | ChatInputCommandInteraction): Promise<undefined | SlashCommandExecuteData>;
97
64
  /**
98
65
  * Execute a Message command
99
66
  * @param message Message command executor
100
67
  * @param prefix Message command prefix
101
68
  */
102
- messageCommandExecute(message: Message, prefix?: string): Promise<void | MessageCommandExecuteData>;
103
- /**
104
- * Registers client slash commands and other application commands
105
- */
106
- registerClientApplicationCommands(): Promise<void>;
69
+ messageCommandExecute(message: Message, prefix?: string): Promise<undefined | MessageCommandExecuteData>;
107
70
  /**
108
71
  * Get a message from config
109
72
  * @param messageKey Config messages key
110
73
  * @param defaultMessage Default message when the key does not exists
111
74
  */
112
75
  getConfigMessage<T = unknown>(messageKey: string, defaultMessage?: T): T;
113
- /**
114
- * Get command builder by name or alias if it's a message command
115
- * @param command Command name
116
- * @param type Command type
117
- */
118
- findCommand(command: string, type: CommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
119
- findCommand(command: string, type: CommandBuilderType.SlashCommand): SlashCommandBuilder | undefined;
120
- /**
121
- * Returns true if client logs is enabled
122
- */
123
- isClientLogsEnabled(): boolean;
124
76
  /**
125
77
  * Emits the {@link RecipleClientEvents["recipleReplyError"]} event
126
78
  * @param error Received Error
@@ -138,8 +90,8 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
138
90
  * @param command Command builder
139
91
  * @param executeData Command execute data
140
92
  */
141
- protected _executeCommand(command: SlashCommandBuilder, executeData: SlashCommandExecuteData): Promise<SlashCommandExecuteData | void>;
142
- protected _executeCommand(command: MessageCommandBuilder, executeData: MessageCommandExecuteData): Promise<MessageCommandExecuteData | void>;
93
+ protected _executeCommand(command: SlashCommandBuilder, executeData: SlashCommandExecuteData): Promise<SlashCommandExecuteData | undefined>;
94
+ protected _executeCommand(command: MessageCommandBuilder, executeData: MessageCommandExecuteData): Promise<MessageCommandExecuteData | undefined>;
143
95
  /**
144
96
  * Error message when a command fails to execute
145
97
  * @param err Received error
@@ -0,0 +1,56 @@
1
+ import { GuildResolvable, RestOrArray } from 'discord.js';
2
+ import { AnyCommandBuilder, AnyCommandData } from '../types/builders';
3
+ import { RecipleClient } from './RecipleClient';
4
+ /**
5
+ * Reciple script object
6
+ */
7
+ export interface RecipleScript {
8
+ /**
9
+ * Supported reciple versions
10
+ */
11
+ versions: string | string[];
12
+ /**
13
+ * Module commands
14
+ */
15
+ commands?: (AnyCommandBuilder | AnyCommandData)[];
16
+ /**
17
+ * Action on module start
18
+ * @param client Bot client
19
+ */
20
+ onStart(client: RecipleClient<false>): boolean | Promise<boolean>;
21
+ /**
22
+ * Action on bot ready
23
+ * @param client Bot client
24
+ */
25
+ onLoad?(client: RecipleClient<true>): void | Promise<void>;
26
+ /**
27
+ * Action when unloading this module
28
+ * @param reason Unload reason
29
+ * @param client Bot client
30
+ */
31
+ onUnLoad?(reason: unknown, client: RecipleClient<true>): void | Promise<void>;
32
+ }
33
+ export interface RecipleModuleOptions<M = unknown> {
34
+ client: RecipleClient;
35
+ script: RecipleScript;
36
+ filePath?: string;
37
+ metadata?: M;
38
+ }
39
+ export declare class RecipleModule<M = unknown> {
40
+ readonly id: string;
41
+ readonly client: RecipleClient;
42
+ readonly commands: AnyCommandBuilder[];
43
+ readonly script: RecipleScript;
44
+ readonly filePath?: string;
45
+ metadata?: M;
46
+ get displayName(): string;
47
+ constructor(options: RecipleModuleOptions<M>);
48
+ start(): Promise<boolean>;
49
+ load(resolveCommands?: boolean): Promise<void>;
50
+ unLoad(reason?: any): Promise<void>;
51
+ registerSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
52
+ unregisterSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
53
+ updateSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
54
+ resolveCommands(): AnyCommandBuilder[];
55
+ toString(): string;
56
+ }
@@ -1,7 +1,7 @@
1
- import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
2
2
  import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
3
3
  import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
4
- import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
4
+ import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
5
5
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
6
6
  import { Command } from 'fallout-utility';
7
7
  /**
@@ -53,20 +53,20 @@ export interface MessageCommandValidatedOption {
53
53
  /**
54
54
  * Halt data for message command
55
55
  */
56
- export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.MessageCommand, T>;
56
+ export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<CommandType.MessageCommand, T>;
57
57
  /**
58
58
  * Message command halt function
59
59
  */
60
- export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.MessageCommand, T>;
60
+ export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandType.MessageCommand, T>;
61
61
  /**
62
62
  * Message command execute function
63
63
  */
64
- export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.MessageCommand, T>;
64
+ export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.MessageCommand, T>;
65
65
  /**
66
66
  * Reciple builder for message command
67
67
  */
68
68
  export declare class MessageCommandBuilder<T = unknown> implements SharedCommandBuilderProperties<T> {
69
- readonly type = CommandBuilderType.MessageCommand;
69
+ readonly type = CommandType.MessageCommand;
70
70
  name: string;
71
71
  description: string;
72
72
  cooldown: number;
@@ -80,7 +80,7 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
80
80
  halt?: MessageCommandHaltFunction<T>;
81
81
  execute: MessageCommandExecuteFunction<T>;
82
82
  metadata?: T;
83
- constructor(data?: Partial<Omit<MessageCommandData<T>, "type">>);
83
+ constructor(data?: Partial<Omit<MessageCommandData<T>, 'type'>>);
84
84
  /**
85
85
  * Sets the command name
86
86
  * @param name Command name
@@ -1,4 +1,4 @@
1
- import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, AnySlashCommandBuilder, SlashCommandData, AnySlashCommandOptionData, AnySlashCommandOptionBuilder } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, AnySlashCommandBuilder, SlashCommandData, AnySlashCommandOptionData, AnySlashCommandOptionBuilder } from '../../types/builders';
2
2
  import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
3
3
  import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, SlashCommandRoleOption, SlashCommandAttachmentOption, SlashCommandMentionableOption, SlashCommandStringOption, SlashCommandIntegerOption, SlashCommandNumberOption, SharedSlashCommandOptions } from 'discord.js';
4
4
  /**
@@ -17,42 +17,42 @@ export interface SlashCommandExecuteData<T = unknown> extends BaseCommandExecute
17
17
  /**
18
18
  * Slash command halt data
19
19
  */
20
- export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.SlashCommand, T>;
20
+ export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandType.SlashCommand, T>;
21
21
  /**
22
22
  * Slash command halt function
23
23
  */
24
- export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.SlashCommand, T>;
24
+ export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandType.SlashCommand, T>;
25
25
  /**
26
26
  * Slash command execute function
27
27
  */
28
- export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.SlashCommand, T>;
29
- export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, "addBooleanOption" | "addUserOption" | "addChannelOption" | "addRoleOption" | "addAttachmentOption" | "addMentionableOption" | "addStringOption" | "addIntegerOption" | "addNumberOption">;
30
- export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, "addSubcommand" | "addSubcommandGroup">;
28
+ export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.SlashCommand, T>;
29
+ export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addBooleanOption' | 'addUserOption' | 'addChannelOption' | 'addRoleOption' | 'addAttachmentOption' | 'addMentionableOption' | 'addStringOption' | 'addIntegerOption' | 'addNumberOption'>;
30
+ export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addSubcommand' | 'addSubcommandGroup'>;
31
31
  export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
32
32
  addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
33
33
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
34
- addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
35
- addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
36
- addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
37
- addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
38
- addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
39
- addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
40
- addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
41
- addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
42
- addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
34
+ addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
35
+ addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
36
+ addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
37
+ addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
38
+ addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
39
+ addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
40
+ addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'>)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
41
+ addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'>)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
42
+ addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'>)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
43
43
  }
44
44
  /**
45
45
  * Reciple builder for slash command
46
46
  */
47
47
  export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
48
- readonly type = CommandBuilderType.SlashCommand;
48
+ readonly type = CommandType.SlashCommand;
49
49
  cooldown: number;
50
50
  requiredBotPermissions: PermissionResolvable[];
51
51
  requiredMemberPermissions: PermissionResolvable[];
52
52
  halt?: SlashCommandHaltFunction<T>;
53
53
  execute: SlashCommandExecuteFunction<T>;
54
54
  metadata?: T;
55
- constructor(data?: Partial<Omit<SlashCommandData<T>, "type">>);
55
+ constructor(data?: Partial<Omit<SlashCommandData<T>, 'type'>>);
56
56
  setCooldown(cooldown: number): this;
57
57
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
58
58
  setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
@@ -0,0 +1,15 @@
1
+ import { ApplicationCommand, ApplicationCommandData, ContextMenuCommandBuilder, GuildResolvable, RestOrArray, RESTPostAPIApplicationCommandsJSONBody, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
2
+ import { AnySlashCommandBuilder } from '../../types/builders';
3
+ import { RecipleClient } from '../RecipleClient';
4
+ export declare type ApplicationCommandBuilder = AnySlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
5
+ export declare class ApplicationCommandManager {
6
+ readonly client: RecipleClient;
7
+ constructor(client: RecipleClient);
8
+ set(commands: (ApplicationCommandBuilder | ApplicationCommandData)[], ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
9
+ add(command: ApplicationCommandBuilder | ApplicationCommandData, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
10
+ remove(command: string | ApplicationCommand, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
11
+ edit(command: string | ApplicationCommand, newCommand: ApplicationCommandBuilder | ApplicationCommandData, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
12
+ get(command: ApplicationCommandData | ApplicationCommandBuilder | string, guild?: GuildResolvable): ApplicationCommand | undefined;
13
+ fetch(commandId: string, guild?: GuildResolvable): Promise<ApplicationCommand>;
14
+ protected parseCommands(commands: (ApplicationCommandData | ApplicationCommandBuilder | RESTPostAPIApplicationCommandsJSONBody)[], setPermissions?: boolean): (ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody)[];
15
+ }
@@ -0,0 +1,37 @@
1
+ import { ApplicationCommandData, Collection, GuildResolvable, RestOrArray } from 'discord.js';
2
+ import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandType, MessageCommandData, SlashCommandData } from '../../types/builders';
3
+ import { MessageCommandBuilder } from '../builders/MessageCommandBuilder';
4
+ import { SlashCommandBuilder } from '../builders/SlashCommandBuilder';
5
+ import { RecipleClient } from '../RecipleClient';
6
+ import { ApplicationCommandBuilder } from './ApplicationCommandManager';
7
+ export interface ClientCommandManagerOptions {
8
+ client: RecipleClient;
9
+ messageCommands?: (MessageCommandBuilder | MessageCommandData)[];
10
+ slashCommands?: (AnySlashCommandBuilder | SlashCommandData)[];
11
+ }
12
+ export declare class ClientCommandManager {
13
+ readonly client: RecipleClient;
14
+ readonly slashCommands: Collection<string, AnySlashCommandBuilder>;
15
+ readonly messageCommands: Collection<string, MessageCommandBuilder>;
16
+ readonly additionalApplicationCommands: (ApplicationCommandBuilder | ApplicationCommandData)[];
17
+ get applicationCommandsSize(): number;
18
+ constructor(options: ClientCommandManagerOptions);
19
+ /**
20
+ * Add command to command manager
21
+ * @param commands Any command data or builder
22
+ */
23
+ add(...commands: RestOrArray<AnyCommandBuilder | AnyCommandData>): this;
24
+ /**
25
+ * Get command builder by name or alias if it's a message command
26
+ * @param command Command name
27
+ * @param type Command type
28
+ */
29
+ get(command: string, type?: undefined): AnyCommandBuilder | undefined;
30
+ get(command: string, type?: CommandType.MessageCommand): MessageCommandBuilder | undefined;
31
+ get(command: string, type?: CommandType.SlashCommand): SlashCommandBuilder | undefined;
32
+ /**
33
+ * Register application commands
34
+ * @param guilds Register application commands to guilds
35
+ */
36
+ registerApplicationCommands(...guilds: RestOrArray<GuildResolvable>): Promise<this>;
37
+ }
@@ -0,0 +1,19 @@
1
+ import { Collection, RestOrArray } from 'discord.js';
2
+ import { ClientModuleManagerGetModulesFromFilesOptions } 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
+ startModules(modules: RecipleModule[], ignoreErrors?: boolean): Promise<RecipleModule[]>;
14
+ loadModules(modules: RecipleModule[], addModuleCommandsToClient?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
15
+ unLoadModules(modules: RecipleModule[], removeUnloadedModules?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
16
+ getModulesFromFiles(options: ClientModuleManagerGetModulesFromFilesOptions): Promise<RecipleModule[]>;
17
+ static validateScript(script: unknown): script is RecipleScript;
18
+ getModuleFiles(...folders: RestOrArray<string>): Promise<string[]>;
19
+ }
@@ -1,5 +1,5 @@
1
1
  import { Guild, RestOrArray, TextBasedChannel, User } from 'discord.js';
2
- import { CommandBuilderType } from '../types/builders';
2
+ import { CommandType } from '../../types/builders';
3
3
  /**
4
4
  * cooled-down user object interface
5
5
  */
@@ -15,7 +15,7 @@ export interface CooledDownUser {
15
15
  /**
16
16
  * Command type
17
17
  */
18
- type: CommandBuilderType;
18
+ type: CommandType;
19
19
  /**
20
20
  * In guild
21
21
  */
@@ -43,8 +43,9 @@ export declare class CommandCooldownManager extends Array<CooledDownUser> {
43
43
  * Remove cooldown from specific user, channel or guild
44
44
  * @param options Remove cooldown data options
45
45
  * @param limit Remove cooldown data limit
46
+ * @returns Returns the removed values
46
47
  */
47
- remove(options: Partial<CooledDownUser>, limit?: number): void;
48
+ remove(options: Partial<CooledDownUser>, limit?: number): CooledDownUser[];
48
49
  /**
49
50
  * Check if the given user is cooled-down
50
51
  * @param options Options to identify if user is on cooldown
@@ -1,4 +1,4 @@
1
- import { MessageCommandValidatedOption } from './builders/MessageCommandBuilder';
1
+ import { MessageCommandValidatedOption } from '../builders/MessageCommandBuilder';
2
2
  import { RestOrArray } from 'discord.js';
3
3
  /**
4
4
  * Validated message options manager
@@ -25,11 +25,11 @@ export declare type AnyCommandExecuteFunction<T = unknown> = SlashCommandExecute
25
25
  /**
26
26
  * Command halt function
27
27
  */
28
- export declare type CommandHaltFunction<T extends CommandBuilderType, M = unknown> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData<M> : T extends CommandBuilderType.MessageCommand ? MessageCommandHaltData<M> : SlashCommandHaltData<M> | MessageCommandHaltData<M>) => Awaitable<boolean | null | undefined | void>;
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
29
  /**
30
30
  * Command execute function
31
31
  */
32
- export declare type CommandExecuteFunction<T extends CommandBuilderType, M = unknown> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData<M> : SlashCommandExecuteData<M> | MessageCommandExecuteData<M>) => Awaitable<void>;
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
33
  /**
34
34
  * Message command options resolvable
35
35
  */
@@ -53,7 +53,7 @@ export declare type AnySlashCommandOptionsOnlyOptionBuilder = SlashCommandAttach
53
53
  /**
54
54
  * Types of command builders
55
55
  */
56
- export declare enum CommandBuilderType {
56
+ export declare enum CommandType {
57
57
  MessageCommand = 0,
58
58
  SlashCommand = 1
59
59
  }
@@ -61,7 +61,7 @@ export declare enum CommandBuilderType {
61
61
  * Shared command builder methods and properties
62
62
  */
63
63
  export interface SharedCommandBuilderProperties<T = unknown> {
64
- readonly type: CommandBuilderType;
64
+ readonly type: CommandType;
65
65
  cooldown: number;
66
66
  requiredBotPermissions: PermissionResolvable[];
67
67
  requiredMemberPermissions: PermissionResolvable[];
@@ -88,12 +88,12 @@ export interface SharedCommandBuilderProperties<T = unknown> {
88
88
  * Function when the command is interupted
89
89
  * @param halt Function to execute when command is halted
90
90
  */
91
- setHalt(halt?: this["halt"]): this;
91
+ setHalt(halt?: this['halt']): this;
92
92
  /**
93
93
  * Function when the command is executed
94
94
  * @param execute Function to execute when the command is called
95
95
  */
96
- setExecute(execute: this["execute"]): this;
96
+ setExecute(execute: this['execute']): this;
97
97
  /**
98
98
  * Set a command metadata
99
99
  * @param metadata Command metadata
@@ -110,8 +110,8 @@ export interface SharedCommandDataProperties {
110
110
  /**
111
111
  * Slash command object data interface
112
112
  */
113
- export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
114
- type: CommandBuilderType.SlashCommand;
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
115
  nameLocalizations?: LocalizationMap;
116
116
  descriptionLocalizations?: LocalizationMap;
117
117
  options?: (AnySlashCommandOptionData | AnySlashCommandOptionBuilder)[];
@@ -124,7 +124,7 @@ export interface SlashCommandData<T = unknown> extends SharedCommandDataProperti
124
124
  halt?: SlashCommandHaltFunction<T>;
125
125
  execute: SlashCommandExecuteFunction<T>;
126
126
  }
127
- export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
127
+ export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
128
128
  choices?: {
129
129
  name: string;
130
130
  nameLocalizations?: LocalizationMap;
@@ -133,13 +133,13 @@ export interface SharedSlashCommandOptionData<V = string | number> extends Share
133
133
  autocomplete?: boolean;
134
134
  required?: boolean;
135
135
  }
136
- export interface SlashCommandAttachmentOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
136
+ export interface SlashCommandAttachmentOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
137
137
  type: ApplicationCommandOptionType.Attachment;
138
138
  }
139
- export interface SlashCommandBooleanOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
139
+ export interface SlashCommandBooleanOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
140
140
  type: ApplicationCommandOptionType.Boolean;
141
141
  }
142
- export interface SlashCommandChannelOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
142
+ export interface SlashCommandChannelOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
143
143
  type: ApplicationCommandOptionType.Channel;
144
144
  channelTypes?: ApplicationCommandOptionAllowedChannelTypes[];
145
145
  }
@@ -148,7 +148,7 @@ export interface SlashCommandIntegerOptionData extends SharedSlashCommandOptionD
148
148
  minValue?: number;
149
149
  maxValue?: number;
150
150
  }
151
- export interface SlashCommandMentionableOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
151
+ export interface SlashCommandMentionableOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
152
152
  type: ApplicationCommandOptionType.Mentionable;
153
153
  }
154
154
  export interface SlashCommandNumberOptionData extends SharedSlashCommandOptionData<number> {
@@ -156,7 +156,7 @@ export interface SlashCommandNumberOptionData extends SharedSlashCommandOptionDa
156
156
  minValue?: number;
157
157
  maxValue?: number;
158
158
  }
159
- export interface SlashCommandRoleOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
159
+ export interface SlashCommandRoleOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
160
160
  type: ApplicationCommandOptionType.Role;
161
161
  }
162
162
  export interface SlashCommandStringOptionData extends SharedSlashCommandOptionData<string> {
@@ -164,22 +164,22 @@ export interface SlashCommandStringOptionData extends SharedSlashCommandOptionDa
164
164
  minLength?: number;
165
165
  maxLength?: number;
166
166
  }
167
- export interface SlashCommandUserOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
167
+ export interface SlashCommandUserOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
168
168
  type: ApplicationCommandOptionType.User;
169
169
  }
170
- export interface SlashCommandSubCommandData extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
170
+ export interface SlashCommandSubCommandData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
171
171
  type: ApplicationCommandOptionType.Subcommand;
172
172
  options: (AnySlashCommandOptionsOnlyOptionData | AnySlashCommandOptionsOnlyOptionBuilder)[];
173
173
  }
174
- export interface SlashCommandSubCommandGroupData extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
174
+ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
175
175
  type: ApplicationCommandOptionType.SubcommandGroup;
176
176
  options: (SlashCommandSubCommandData | SlashCommandSubcommandBuilder)[];
177
177
  }
178
178
  /**
179
179
  * Message command object data interface
180
180
  */
181
- export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
182
- type: CommandBuilderType.MessageCommand;
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
183
  aliases?: string[];
184
184
  validateOptions?: boolean;
185
185
  allowExecuteInDM?: boolean;
@@ -1,9 +1,9 @@
1
1
  import { MessageCommandExecuteData, MessageCommandHaltData } from '../classes/builders/MessageCommandBuilder';
2
2
  import { SlashCommandExecuteData, SlashCommandHaltData } from '../classes/builders/SlashCommandBuilder';
3
- import { MessageCommandOptionManager } from '../classes/MessageCommandOptionManager';
4
- import { CooledDownUser } from '../classes/CommandCooldownManager';
3
+ import { MessageCommandOptionManager } from '../classes/managers/MessageCommandOptionManager';
4
+ import { CooledDownUser } from '../classes/managers/CommandCooldownManager';
5
5
  import { RecipleClient } from '../classes/RecipleClient';
6
- import { CommandBuilderType } from '../types/builders';
6
+ import { CommandType } from '../types/builders';
7
7
  /**
8
8
  * Any command halt data
9
9
  */
@@ -11,7 +11,7 @@ export declare type AnyCommandHaltData<T = unknown> = SlashCommandHaltData<T> |
11
11
  /**
12
12
  * command halt data
13
13
  */
14
- export declare type CommandHaltData<T extends CommandBuilderType, M = unknown> = CommandErrorData<T, M> | CommandCooldownData<T, M> | (T extends CommandBuilderType.SlashCommand ? never : CommandInvalidArguments<T, M> | CommandMissingArguments<T, M>) | CommandMissingMemberPermissions<T, M> | CommandMissingBotPermissions<T, M>;
14
+ export declare type CommandHaltData<T extends CommandType, M = unknown> = CommandErrorData<T, M> | CommandCooldownData<T, M> | (T extends CommandType.SlashCommand ? never : CommandInvalidArguments<T, M> | CommandMissingArguments<T, M>) | CommandMissingMemberPermissions<T, M> | CommandMissingBotPermissions<T, M>;
15
15
  /**
16
16
  * Any command execute data
17
17
  */
@@ -28,7 +28,7 @@ export interface BaseCommandExecuteData {
28
28
  /**
29
29
  * Command halt reason base
30
30
  */
31
- export interface BaseCommandHaltData<T extends CommandBuilderType, M = unknown> {
31
+ export interface BaseCommandHaltData<T extends CommandType, M = unknown> {
32
32
  /**
33
33
  * Halt reason
34
34
  */
@@ -36,36 +36,36 @@ export interface BaseCommandHaltData<T extends CommandBuilderType, M = unknown>
36
36
  /**
37
37
  * Command execute da6a
38
38
  */
39
- executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData<M> : AnyCommandExecuteData<M>;
39
+ executeData: T extends CommandType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandType.MessageCommand ? MessageCommandExecuteData<M> : AnyCommandExecuteData<M>;
40
40
  }
41
- export interface CommandErrorData<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
41
+ export interface CommandErrorData<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
42
42
  reason: CommandHaltReason.Error;
43
43
  /**
44
44
  * Caught error
45
45
  */
46
46
  error: any;
47
47
  }
48
- export interface CommandCooldownData<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M>, CooledDownUser {
48
+ export interface CommandCooldownData<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M>, CooledDownUser {
49
49
  reason: CommandHaltReason.Cooldown;
50
50
  }
51
- export interface CommandInvalidArguments<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
51
+ export interface CommandInvalidArguments<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
52
52
  reason: CommandHaltReason.InvalidArguments;
53
53
  /**
54
54
  * Arguments that are invalid
55
55
  */
56
56
  invalidArguments: MessageCommandOptionManager;
57
57
  }
58
- export interface CommandMissingArguments<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
58
+ export interface CommandMissingArguments<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
59
59
  reason: CommandHaltReason.MissingArguments;
60
60
  /**
61
61
  * Arguments that are missing
62
62
  */
63
63
  missingArguments: MessageCommandOptionManager;
64
64
  }
65
- export interface CommandMissingMemberPermissions<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
65
+ export interface CommandMissingMemberPermissions<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
66
66
  reason: CommandHaltReason.MissingMemberPermissions;
67
67
  }
68
- export interface CommandMissingBotPermissions<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
68
+ export interface CommandMissingBotPermissions<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
69
69
  reason: CommandHaltReason.MissingBotPermissions;
70
70
  }
71
71
  /**