reciple 6.0.0-dev.2 → 6.0.0-dev.21

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 (48) hide show
  1. package/dist/lib/bin.mjs +65 -0
  2. package/dist/lib/esm.mjs +1 -0
  3. package/dist/{cjs → lib}/index.js +18 -17
  4. package/dist/{cjs → lib}/reciple/classes/RecipleClient.js +19 -22
  5. package/dist/{cjs → lib}/reciple/classes/RecipleConfig.js +10 -10
  6. package/dist/lib/reciple/classes/RecipleModule.js +94 -0
  7. package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +325 -0
  8. package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandOptionBuilder.js +35 -13
  9. package/dist/{cjs → lib}/reciple/classes/builders/SlashCommandBuilder.js +42 -15
  10. package/dist/{cjs → lib}/reciple/classes/managers/ApplicationCommandManager.js +64 -23
  11. package/dist/{cjs → lib}/reciple/classes/managers/CommandCooldownManager.js +0 -0
  12. package/dist/{cjs/reciple/classes/managers/ClientCommandManager.js → lib/reciple/classes/managers/CommandManager.js} +14 -15
  13. package/dist/{cjs → lib}/reciple/classes/managers/MessageCommandOptionManager.js +0 -0
  14. package/dist/lib/reciple/classes/managers/ModuleManager.js +179 -0
  15. package/dist/{cjs → lib}/reciple/flags.js +2 -2
  16. package/dist/{cjs → lib}/reciple/permissions.js +0 -0
  17. package/dist/lib/reciple/types/builders.js +11 -0
  18. package/dist/{cjs → lib}/reciple/types/commands.js +6 -6
  19. package/dist/{cjs → lib}/reciple/types/paramOptions.js +0 -0
  20. package/dist/{cjs/reciple/logger.js → lib/reciple/util.js} +33 -2
  21. package/dist/{cjs → lib}/reciple/version.js +0 -1
  22. package/dist/types/{bin.d.ts → bin.d.mts} +0 -0
  23. package/dist/types/esm.d.mts +1 -0
  24. package/dist/types/index.d.ts +18 -17
  25. package/dist/types/reciple/classes/RecipleClient.d.ts +7 -5
  26. package/dist/types/reciple/classes/RecipleConfig.d.ts +3 -2
  27. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -0
  28. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +60 -26
  29. package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +15 -7
  30. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +20 -10
  31. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +43 -10
  32. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +2 -2
  33. package/dist/types/reciple/classes/managers/{ClientCommandManager.d.ts → CommandManager.d.ts} +6 -7
  34. package/dist/types/reciple/classes/managers/ModuleManager.d.ts +49 -0
  35. package/dist/types/reciple/types/builders.d.ts +8 -8
  36. package/dist/types/reciple/types/commands.d.ts +16 -16
  37. package/dist/types/reciple/types/paramOptions.d.ts +79 -18
  38. package/dist/types/reciple/util.d.ts +11 -0
  39. package/package.json +28 -21
  40. package/resource/reciple.yml +25 -22
  41. package/dist/cjs/bin.js +0 -50
  42. package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +0 -242
  43. package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +0 -193
  44. package/dist/cjs/reciple/types/builders.js +0 -11
  45. package/dist/cjs/reciple/util.js +0 -32
  46. package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +0 -79
  47. package/dist/types/reciple/logger.d.ts +0 -8
  48. package/docs/README.md +0 -1
@@ -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,4 +1,4 @@
1
- import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData, MessageCommandOptionResolvable } from '../../types/builders';
2
2
  import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
3
3
  import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
4
4
  import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
@@ -53,33 +53,57 @@ 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;
70
- name: string;
71
- description: string;
72
- cooldown: number;
73
- aliases: string[];
74
- validateOptions: boolean;
75
- options: MessageCommandOptionBuilder[];
76
- requiredBotPermissions: PermissionResolvable[];
77
- requiredMemberPermissions: PermissionResolvable[];
78
- allowExecuteInDM: boolean;
79
- allowExecuteByBots: boolean;
80
- halt?: MessageCommandHaltFunction<T>;
81
- execute: MessageCommandExecuteFunction<T>;
69
+ readonly type = CommandType.MessageCommand;
70
+ private _name;
71
+ private _description;
72
+ private _cooldown;
73
+ private _aliases;
74
+ private _validateOptions;
75
+ private _options;
76
+ private _requiredBotPermissions;
77
+ private _requiredMemberPermissions;
78
+ private _allowExecuteInDM;
79
+ private _allowExecuteByBots;
80
+ private _halt?;
81
+ private _execute;
82
82
  metadata?: T;
83
+ get name(): typeof this._name;
84
+ get description(): typeof this._description;
85
+ get cooldown(): typeof this._cooldown;
86
+ get aliases(): typeof this._aliases;
87
+ get validateOptions(): typeof this._validateOptions;
88
+ get options(): MessageCommandOptionResolvable[];
89
+ get requiredBotPermissions(): typeof this._requiredBotPermissions;
90
+ get requiredMemberPermissions(): typeof this._requiredMemberPermissions;
91
+ get allowExecuteInDM(): typeof this._allowExecuteInDM;
92
+ get allowExecuteByBots(): typeof this._allowExecuteByBots;
93
+ get halt(): typeof this._halt;
94
+ get execute(): typeof this._execute;
95
+ set name(name: typeof this._name);
96
+ set description(description: typeof this._description);
97
+ set cooldown(cooldown: typeof this._cooldown);
98
+ set aliases(aliases: typeof this._aliases);
99
+ set validateOptions(validate: typeof this._validateOptions);
100
+ set options(options: MessageCommandOptionResolvable[]);
101
+ set requiredBotPermissions(permissions: typeof this._requiredBotPermissions);
102
+ set requiredMemberPermissions(permissions: typeof this._requiredMemberPermissions);
103
+ set allowExecuteInDM(allow: typeof this._allowExecuteInDM);
104
+ set allowExecuteByBots(allow: typeof this._allowExecuteByBots);
105
+ set halt(halt: typeof this._halt);
106
+ set execute(execute: typeof this._execute);
83
107
  constructor(data?: Partial<Omit<MessageCommandData<T>, 'type'>>);
84
108
  /**
85
109
  * Sets the command name
@@ -96,6 +120,11 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
96
120
  * @param aliases Command aliases
97
121
  */
98
122
  addAliases(...aliases: RestOrArray<string>): this;
123
+ /**
124
+ * Replace aliases from command builder
125
+ * @param aliases Command aliases
126
+ */
127
+ setAliases(...aliases: RestOrArray<string>): this;
99
128
  /**
100
129
  * Set if command can be executed in dms
101
130
  * @param allowExecuteInDM `true` if the command can execute in DMs
@@ -107,10 +136,15 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
107
136
  */
108
137
  setAllowExecuteByBots(allowExecuteByBots: boolean): this;
109
138
  /**
110
- * Add option to the command
111
- * @param option Message option builder
139
+ * Add options to command
140
+ * @param options Message options
141
+ */
142
+ addOptions(...options: RestOrArray<MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)>): this;
143
+ /**
144
+ * Replace options from command
145
+ * @params options Message options
112
146
  */
113
- addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): this;
147
+ setOptions(...options: RestOrArray<MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)>): this;
114
148
  /**
115
149
  * Validate options before executing
116
150
  * @param validateOptions `true` if the command options needs to be validated before executing
@@ -141,10 +175,10 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
141
175
  * @param executeData data to check
142
176
  */
143
177
  static isMessageCommandExecuteData(executeData: unknown): executeData is MessageCommandExecuteData;
178
+ /**
179
+ * Validate message command options
180
+ * @param builder Command builder
181
+ * @param options Parsed command args
182
+ */
183
+ static validateOptions(builder: MessageCommandBuilder, options: Command): Promise<MessageCommandOptionManager>;
144
184
  }
145
- /**
146
- * Validate message command options
147
- * @param builder Command builder
148
- * @param options Parsed command args
149
- */
150
- export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: Command): Promise<MessageCommandOptionManager>;
@@ -1,13 +1,21 @@
1
- import { MessageCommandOptionData } from '../../types/builders';
1
+ import { MessageCommandOptionData, MessageCommandOptionResolvable } from '../../types/builders';
2
2
  import { Awaitable } from 'discord.js';
3
3
  /**
4
4
  * Option builder for MessageCommandBuilder
5
5
  */
6
6
  export declare class MessageCommandOptionBuilder {
7
- name: string;
8
- description: string;
9
- required: boolean;
10
- validator: (value: string) => Awaitable<boolean>;
7
+ private _name;
8
+ private _description;
9
+ private _required;
10
+ private _validator?;
11
+ get name(): typeof this._name;
12
+ get description(): typeof this._description;
13
+ get required(): typeof this._required;
14
+ get validator(): typeof this._validator;
15
+ set name(name: typeof this._name);
16
+ set description(description: typeof this._description);
17
+ set required(required: typeof this._required);
18
+ set validator(validator: typeof this._validator);
11
19
  constructor(data?: Partial<MessageCommandOptionData>);
12
20
  /**
13
21
  * Set command option name
@@ -28,13 +36,13 @@ export declare class MessageCommandOptionBuilder {
28
36
  * Set your custom function to validate given value for this option
29
37
  * @param validator Custom function to validate value given for this option
30
38
  */
31
- setValidator(validator: (value: string) => Awaitable<boolean>): this;
39
+ setValidator(validator?: (value: string) => Awaitable<boolean>): this;
32
40
  toJSON(): MessageCommandOptionData;
33
41
  /**
34
42
  * Resolves message command option data/builder
35
43
  * @param option Option data to resolve
36
44
  */
37
- static resolveMessageCommandOption(option: MessageCommandOptionBuilder | MessageCommandOptionBuilder): MessageCommandOptionBuilder;
45
+ static resolveMessageCommandOption(option: MessageCommandOptionResolvable): MessageCommandOptionBuilder;
38
46
  /**
39
47
  * Is a Message command option builder
40
48
  * @param builder data to check
@@ -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,15 +17,15 @@ 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>;
28
+ export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.SlashCommand, T>;
29
29
  export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addBooleanOption' | 'addUserOption' | 'addChannelOption' | 'addRoleOption' | 'addAttachmentOption' | 'addMentionableOption' | 'addStringOption' | 'addIntegerOption' | 'addNumberOption'>;
30
30
  export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addSubcommand' | 'addSubcommandGroup'>;
31
31
  export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
@@ -45,13 +45,23 @@ export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandB
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;
49
- cooldown: number;
50
- requiredBotPermissions: PermissionResolvable[];
51
- requiredMemberPermissions: PermissionResolvable[];
52
- halt?: SlashCommandHaltFunction<T>;
53
- execute: SlashCommandExecuteFunction<T>;
48
+ readonly type = CommandType.SlashCommand;
49
+ private _cooldown;
50
+ private _requiredBotPermissions;
51
+ private _requiredMemberPermissions;
52
+ private _halt?;
53
+ private _execute;
54
54
  metadata?: T;
55
+ get cooldown(): typeof this._cooldown;
56
+ get requiredBotPermissions(): typeof this._requiredBotPermissions;
57
+ get requiredMemberPermissions(): typeof this._requiredMemberPermissions;
58
+ get halt(): typeof this._halt;
59
+ get execute(): typeof this._execute;
60
+ set cooldown(cooldown: typeof this._cooldown);
61
+ set requiredBotPermissions(permissions: typeof this._requiredBotPermissions);
62
+ set requiredMemberPermissions(permissions: typeof this._requiredMemberPermissions);
63
+ set halt(halt: typeof this._halt);
64
+ set execute(execute: typeof this._execute);
55
65
  constructor(data?: Partial<Omit<SlashCommandData<T>, 'type'>>);
56
66
  setCooldown(cooldown: number): this;
57
67
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
@@ -1,20 +1,53 @@
1
- import { ApplicationCommand, ApplicationCommandData, ContextMenuCommandBuilder, GuildResolvable, RESTPostAPIApplicationCommandsJSONBody, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
1
+ import { ApplicationCommand, ApplicationCommandData, ContextMenuCommandBuilder, GuildResolvable, RestOrArray, RESTPostAPIApplicationCommandsJSONBody, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
2
2
  import { AnySlashCommandBuilder } from '../../types/builders';
3
3
  import { RecipleClient } from '../RecipleClient';
4
4
  export declare type ApplicationCommandBuilder = AnySlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
5
5
  export declare class ApplicationCommandManager {
6
6
  readonly client: RecipleClient;
7
- get commands(): import("discord.js").ApplicationCommandManager<ApplicationCommand<{
8
- guild: GuildResolvable;
9
- }>, {
10
- guild: GuildResolvable;
11
- }, null> | undefined;
7
+ get commands(): (DiscordJsSlashCommandBuilder | import("../builders/SlashCommandBuilder").SlashCommandOptionsOnlyBuilder<unknown> | import("../builders/SlashCommandBuilder").SlashCommandSubcommandsOnlyBuilder<unknown> | ContextMenuCommandBuilder | import("discord.js").UserApplicationCommandData | import("discord.js").MessageApplicationCommandData | import("discord.js").ChatInputApplicationCommandData)[];
8
+ get size(): number;
12
9
  constructor(client: RecipleClient);
13
- set(commands: (ApplicationCommandBuilder | ApplicationCommandData)[], guilds?: GuildResolvable[]): Promise<void>;
14
- add(command: ApplicationCommandBuilder | ApplicationCommandData, guilds?: GuildResolvable[]): Promise<void>;
15
- remove(command: string | ApplicationCommand, guilds?: GuildResolvable[]): Promise<void>;
16
- edit(command: string | ApplicationCommand, newCommand: ApplicationCommandBuilder | ApplicationCommandData, guilds?: GuildResolvable[]): Promise<void>;
10
+ /**
11
+ * Sets application commands globally or in guilds
12
+ * @param commands Application commands
13
+ * @param guilds set only to guilds
14
+ */
15
+ set(commands: (ApplicationCommandBuilder | ApplicationCommandData)[], ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
16
+ /**
17
+ * Add command globally or in guilds
18
+ * @param command Application command
19
+ * @param guilds add only in guilds
20
+ */
21
+ add(command: ApplicationCommandBuilder | ApplicationCommandData, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
22
+ /**
23
+ * Remove application command globally or in guilds
24
+ * @param command id of application commmand or ApplicationCommand class
25
+ * @param guilds Remove from guilds
26
+ */
27
+ remove(command: string | ApplicationCommand, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
28
+ /**
29
+ * Edit application command globally or in guilds
30
+ * @param command id of application command or ApplicationCommand class
31
+ * @param newCommand new application command data
32
+ * @param guilds Edit only from guilds
33
+ */
34
+ edit(command: string | ApplicationCommand, newCommand: ApplicationCommandBuilder | ApplicationCommandData, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
35
+ /**
36
+ * Get application command from cache by application command data, builder, id, or name globally or from guid
37
+ * @param command application command data, builder, id, or name
38
+ * @param guild get command from guild
39
+ */
17
40
  get(command: ApplicationCommandData | ApplicationCommandBuilder | string, guild?: GuildResolvable): ApplicationCommand | undefined;
41
+ /**
42
+ * Fetch application command by id globally or from guild
43
+ * @param commandId command id
44
+ * @param guild fetch from guild
45
+ */
18
46
  fetch(commandId: string, guild?: GuildResolvable): Promise<ApplicationCommand>;
47
+ /**
48
+ * Parse application command builders to command data
49
+ * @param commands Application command builders
50
+ * @param setPermissions set slash commands permissions
51
+ */
19
52
  protected parseCommands(commands: (ApplicationCommandData | ApplicationCommandBuilder | RESTPostAPIApplicationCommandsJSONBody)[], setPermissions?: boolean): (ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody)[];
20
53
  }
@@ -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
  */
@@ -1,21 +1,20 @@
1
1
  import { ApplicationCommandData, Collection, GuildResolvable, RestOrArray } from 'discord.js';
2
- import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandBuilderType, MessageCommandData, SlashCommandData } from '../../types/builders';
2
+ import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandType, MessageCommandData, SlashCommandData } from '../../types/builders';
3
3
  import { MessageCommandBuilder } from '../builders/MessageCommandBuilder';
4
4
  import { SlashCommandBuilder } from '../builders/SlashCommandBuilder';
5
5
  import { RecipleClient } from '../RecipleClient';
6
6
  import { ApplicationCommandBuilder } from './ApplicationCommandManager';
7
- export interface ClientCommandManagerOptions {
7
+ export interface CommandManagerOptions {
8
8
  client: RecipleClient;
9
9
  messageCommands?: (MessageCommandBuilder | MessageCommandData)[];
10
10
  slashCommands?: (AnySlashCommandBuilder | SlashCommandData)[];
11
11
  }
12
- export declare class ClientCommandManager {
12
+ export declare class CommandManager {
13
13
  readonly client: RecipleClient;
14
14
  readonly slashCommands: Collection<string, AnySlashCommandBuilder>;
15
15
  readonly messageCommands: Collection<string, MessageCommandBuilder>;
16
16
  readonly additionalApplicationCommands: (ApplicationCommandBuilder | ApplicationCommandData)[];
17
- get applicationCommandsSize(): number;
18
- constructor(options: ClientCommandManagerOptions);
17
+ constructor(options: CommandManagerOptions);
19
18
  /**
20
19
  * Add command to command manager
21
20
  * @param commands Any command data or builder
@@ -27,8 +26,8 @@ export declare class ClientCommandManager {
27
26
  * @param type Command type
28
27
  */
29
28
  get(command: string, type?: undefined): AnyCommandBuilder | undefined;
30
- get(command: string, type?: CommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
31
- get(command: string, type?: CommandBuilderType.SlashCommand): SlashCommandBuilder | undefined;
29
+ get(command: string, type?: CommandType.MessageCommand): MessageCommandBuilder | undefined;
30
+ get(command: string, type?: CommandType.SlashCommand): SlashCommandBuilder | undefined;
32
31
  /**
33
32
  * Register application commands
34
33
  * @param guilds Register application commands to guilds
@@ -0,0 +1,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
+ }
@@ -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,15 +53,15 @@ export declare type AnySlashCommandOptionsOnlyOptionBuilder = SlashCommandAttach
53
53
  /**
54
54
  * Types of command builders
55
55
  */
56
- export declare enum CommandBuilderType {
57
- MessageCommand = 0,
58
- SlashCommand = 1
56
+ export declare enum CommandType {
57
+ SlashCommand = 1,
58
+ MessageCommand = 2
59
59
  }
60
60
  /**
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[];
@@ -111,7 +111,7 @@ export interface SharedCommandDataProperties {
111
111
  * Slash command object data interface
112
112
  */
113
113
  export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
114
- type: CommandBuilderType.SlashCommand;
114
+ type: CommandType.SlashCommand;
115
115
  nameLocalizations?: LocalizationMap;
116
116
  descriptionLocalizations?: LocalizationMap;
117
117
  options?: (AnySlashCommandOptionData | AnySlashCommandOptionBuilder)[];
@@ -179,7 +179,7 @@ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProper
179
179
  * Message command object data interface
180
180
  */
181
181
  export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
182
- type: CommandBuilderType.MessageCommand;
182
+ type: CommandType.MessageCommand;
183
183
  aliases?: string[];
184
184
  validateOptions?: boolean;
185
185
  allowExecuteInDM?: boolean;
@@ -3,7 +3,7 @@ import { SlashCommandExecuteData, SlashCommandHaltData } from '../classes/builde
3
3
  import { MessageCommandOptionManager } from '../classes/managers/MessageCommandOptionManager';
4
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> = CommandErrorHaltData<T, M> | CommandCooldownHaltData<T, M> | (T extends CommandType.SlashCommand ? never : CommandInvalidArgumentsHaltData<T, M> | CommandMissingArgumentsHaltData<T, M>) | CommandMissingMemberPermissionsHaltData<T, M> | CommandMissingBotPermissionsHaltData<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,46 +36,46 @@ 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 CommandErrorHaltData<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 CommandCooldownHaltData<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 CommandInvalidArgumentsHaltData<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 CommandMissingArgumentsHaltData<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 CommandMissingMemberPermissionsHaltData<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 CommandMissingBotPermissionsHaltData<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
69
69
  reason: CommandHaltReason.MissingBotPermissions;
70
70
  }
71
71
  /**
72
72
  * Command halt reasons
73
73
  */
74
74
  export declare enum CommandHaltReason {
75
- Error = 0,
76
- Cooldown = 1,
77
- InvalidArguments = 2,
78
- MissingArguments = 3,
79
- MissingMemberPermissions = 4,
80
- MissingBotPermissions = 5
75
+ Error = 1,
76
+ Cooldown = 2,
77
+ InvalidArguments = 3,
78
+ MissingArguments = 4,
79
+ MissingMemberPermissions = 5,
80
+ MissingBotPermissions = 6
81
81
  }