reciple 5.5.6 → 6.0.0-dev.1

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 (34) hide show
  1. package/dist/cjs/bin.js +6 -7
  2. package/dist/cjs/index.js +6 -5
  3. package/dist/cjs/reciple/classes/RecipleClient.js +21 -144
  4. package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +13 -2
  5. package/dist/cjs/reciple/classes/builders/MessageCommandOptionBuilder.js +14 -0
  6. package/dist/cjs/reciple/classes/builders/SlashCommandBuilder.js +9 -0
  7. package/dist/cjs/reciple/classes/managers/ApplicationCommandManager.js +137 -0
  8. package/dist/cjs/reciple/classes/managers/ClientCommandManager.js +62 -0
  9. package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +189 -0
  10. package/dist/cjs/reciple/classes/{CommandCooldownManager.js → managers/CommandCooldownManager.js} +8 -5
  11. package/dist/cjs/reciple/classes/{MessageCommandOptionManager.js → managers/MessageCommandOptionManager.js} +0 -0
  12. package/dist/cjs/reciple/permissions.js +0 -3
  13. package/dist/cjs/reciple/util.js +22 -1
  14. package/dist/cjs/reciple/version.js +1 -0
  15. package/dist/types/index.d.ts +6 -5
  16. package/dist/types/reciple/classes/RecipleClient.d.ts +21 -54
  17. package/dist/types/reciple/classes/RecipleConfig.d.ts +6 -0
  18. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +53 -15
  19. package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +10 -0
  20. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +29 -14
  21. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +20 -0
  22. package/dist/types/reciple/classes/managers/ClientCommandManager.d.ts +37 -0
  23. package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +79 -0
  24. package/dist/types/reciple/classes/{CommandCooldownManager.d.ts → managers/CommandCooldownManager.d.ts} +21 -2
  25. package/dist/types/reciple/classes/{MessageCommandOptionManager.d.ts → managers/MessageCommandOptionManager.d.ts} +1 -1
  26. package/dist/types/reciple/modules.d.ts +36 -4
  27. package/dist/types/reciple/permissions.d.ts +4 -2
  28. package/dist/types/reciple/types/builders.d.ts +16 -16
  29. package/dist/types/reciple/types/commands.d.ts +32 -13
  30. package/dist/types/reciple/types/paramOptions.d.ts +17 -16
  31. package/dist/types/reciple/util.d.ts +12 -1
  32. package/package.json +14 -10
  33. package/dist/cjs/reciple/registerApplicationCommands.js +0 -50
  34. package/dist/types/reciple/registerApplicationCommands.d.ts +0 -9
@@ -4,25 +4,31 @@ import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCo
4
4
  /**
5
5
  * Execute data for slash command
6
6
  */
7
- export interface SlashCommandExecuteData<T extends unknown = any> extends BaseCommandExecuteData {
7
+ export interface SlashCommandExecuteData<T = unknown> extends BaseCommandExecuteData {
8
+ /**
9
+ * Command interaction
10
+ */
8
11
  interaction: ChatInputCommandInteraction;
12
+ /**
13
+ * Command Builder
14
+ */
9
15
  builder: AnySlashCommandBuilder<T>;
10
16
  }
11
17
  /**
12
18
  * Slash command halt data
13
19
  */
14
- export declare type SlashCommandHaltData = CommandHaltData<CommandBuilderType.SlashCommand>;
20
+ export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.SlashCommand, T>;
15
21
  /**
16
22
  * Slash command halt function
17
23
  */
18
- export declare type SlashCommandHaltFunction = CommandHaltFunction<CommandBuilderType.SlashCommand>;
24
+ export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.SlashCommand, T>;
19
25
  /**
20
26
  * Slash command execute function
21
27
  */
22
- export declare type SlashCommandExecuteFunction = CommandExecuteFunction<CommandBuilderType.SlashCommand>;
23
- export declare type SlashCommandSubcommandsOnlyBuilder<T extends unknown = any> = Omit<SlashCommandBuilder<T>, "addBooleanOption" | "addUserOption" | "addChannelOption" | "addRoleOption" | "addAttachmentOption" | "addMentionableOption" | "addStringOption" | "addIntegerOption" | "addNumberOption">;
24
- export declare type SlashCommandOptionsOnlyBuilder<T extends unknown = any> = Omit<SlashCommandBuilder<T>, "addSubcommand" | "addSubcommandGroup">;
25
- export interface SlashCommandBuilder<T extends unknown = any> extends DiscordJsSlashCommandBuilder {
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">;
31
+ export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
26
32
  addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
27
33
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
28
34
  addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
@@ -38,36 +44,45 @@ export interface SlashCommandBuilder<T extends unknown = any> extends DiscordJsS
38
44
  /**
39
45
  * Reciple builder for slash command
40
46
  */
41
- export declare class SlashCommandBuilder<T extends unknown = any> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
47
+ export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
42
48
  readonly type = CommandBuilderType.SlashCommand;
43
49
  cooldown: number;
44
50
  requiredBotPermissions: PermissionResolvable[];
45
51
  requiredMemberPermissions: PermissionResolvable[];
46
- halt?: SlashCommandHaltFunction;
47
- execute: SlashCommandExecuteFunction;
52
+ halt?: SlashCommandHaltFunction<T>;
53
+ execute: SlashCommandExecuteFunction<T>;
48
54
  metadata?: T;
49
55
  constructor(data?: Partial<Omit<SlashCommandData<T>, "type">>);
50
56
  setCooldown(cooldown: number): this;
51
57
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
52
58
  setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
53
- setHalt(halt?: SlashCommandHaltFunction | null): this;
54
- setExecute(execute: SlashCommandExecuteFunction): this;
59
+ setHalt(halt?: SlashCommandHaltFunction<T> | null): this;
60
+ setExecute(execute: SlashCommandExecuteFunction<T>): this;
55
61
  setMetadata(metadata?: T): this;
56
62
  /**
57
63
  * Add option builder to command builder
64
+ * @param builder Command/Subcommand builder
65
+ * @param option Option builder
58
66
  */
59
67
  static addOption(builder: SharedSlashCommandOptions | SlashCommandBuilder, option: AnySlashCommandOptionBuilder): SharedSlashCommandOptions;
60
68
  /**
61
69
  * Resolve option data
70
+ * @param option Option dara to resolve
62
71
  */
63
72
  static resolveOption<T extends AnySlashCommandOptionBuilder>(option: AnySlashCommandOptionData): T;
64
- static resolveSlashCommand<T extends unknown = any>(commandData: SlashCommandData<T> | AnySlashCommandBuilder<T>): AnySlashCommandBuilder;
73
+ /**
74
+ * Resolve slash command data/builder
75
+ * @param commandData Command data to resolve
76
+ */
77
+ static resolveSlashCommand<T = unknown>(commandData: SlashCommandData<T> | AnySlashCommandBuilder<T>): AnySlashCommandBuilder<T>;
65
78
  /**
66
79
  * Is a slash command builder
80
+ * @param builder data to check
67
81
  */
68
- static isSlashCommandBuilder<T extends unknown = any>(builder: unknown): builder is AnySlashCommandBuilder<T>;
82
+ static isSlashCommandBuilder<T = unknown>(builder: unknown): builder is AnySlashCommandBuilder<T>;
69
83
  /**
70
84
  * Is a slash command execute data
85
+ * @param executeData data to check
71
86
  */
72
87
  static isSlashCommandExecuteData(executeData: unknown): executeData is SlashCommandExecuteData;
73
88
  }
@@ -0,0 +1,20 @@
1
+ import { ApplicationCommand, ApplicationCommandData, ContextMenuCommandBuilder, GuildResolvable, 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
+ get commands(): import("discord.js").ApplicationCommandManager<ApplicationCommand<{
8
+ guild: GuildResolvable;
9
+ }>, {
10
+ guild: GuildResolvable;
11
+ }, null> | undefined;
12
+ 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>;
17
+ get(command: (ApplicationCommandData | ApplicationCommandBuilder | string), guild?: GuildResolvable): ApplicationCommand | undefined;
18
+ fetch(commandId: string, guild?: GuildResolvable): Promise<ApplicationCommand>;
19
+ protected parseCommands(commands: (ApplicationCommandData | ApplicationCommandBuilder | RESTPostAPIApplicationCommandsJSONBody)[], setPermissions?: boolean): (ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody)[];
20
+ }
@@ -0,0 +1,37 @@
1
+ import { ApplicationCommandData, Collection, GuildResolvable, RestOrArray } from 'discord.js';
2
+ import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandBuilderType, 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?: CommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
31
+ get(command: string, type?: CommandBuilderType.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,79 @@
1
+ import { Collection, GuildResolvable, RestOrArray } from 'discord.js';
2
+ import { AnyCommandBuilder, AnyCommandData } from '../../types/builders';
3
+ import { ModuleManagerResolveFilesOptions } from '../../types/paramOptions';
4
+ import { RecipleClient } from '../RecipleClient';
5
+ /**
6
+ * Reciple script object
7
+ */
8
+ export interface RecipleScript {
9
+ /**
10
+ * Supported reciple versions
11
+ */
12
+ versions: string | string[];
13
+ /**
14
+ * Module commands
15
+ */
16
+ commands?: (AnyCommandBuilder | AnyCommandData)[];
17
+ /**
18
+ * Action on module start
19
+ * @param client Bot client
20
+ */
21
+ onStart(client: RecipleClient<false>): boolean | Promise<boolean>;
22
+ /**
23
+ * Action on bot ready
24
+ * @param client Bot client
25
+ */
26
+ onLoad?(client: RecipleClient<true>): void | Promise<void>;
27
+ }
28
+ /**
29
+ * Reciple module object
30
+ */
31
+ export interface RecipleModule {
32
+ /**
33
+ * Module Id
34
+ */
35
+ id: string;
36
+ /**
37
+ * Module script
38
+ */
39
+ script: RecipleScript;
40
+ /**
41
+ * Module local information
42
+ */
43
+ info: {
44
+ /**
45
+ * Module file name
46
+ */
47
+ filename?: string;
48
+ /**
49
+ * Module local file path
50
+ */
51
+ path?: string;
52
+ };
53
+ }
54
+ export interface ResolvedModule extends RecipleModule {
55
+ commands: AnyCommandBuilder[];
56
+ }
57
+ export interface ResolvedScriptCommands {
58
+ script: RecipleScript;
59
+ commands: AnyCommandBuilder[];
60
+ }
61
+ export interface ClientModuleManagerOptions {
62
+ client: RecipleClient;
63
+ modules?: (RecipleModule & {
64
+ id?: string;
65
+ })[];
66
+ }
67
+ export declare class ClientModuleManager {
68
+ readonly client: RecipleClient;
69
+ readonly modules: Collection<string, ResolvedModule>;
70
+ constructor(options: ClientModuleManagerOptions);
71
+ startModulesFromFiles(options: ModuleManagerResolveFilesOptions): Promise<ResolvedModule[]>;
72
+ resolveModulesFromFiles(options: ModuleManagerResolveFilesOptions): Promise<ResolvedModule[]>;
73
+ resolveScriptCommands(...modules: RestOrArray<RecipleScript>): ResolvedScriptCommands[];
74
+ loadAll(registerApplicationCommands?: boolean, ...registerApplicationCommandsGuilds: RestOrArray<GuildResolvable>): Promise<void>;
75
+ startModule(mod: ResolvedModule): Promise<void>;
76
+ resolveModule(mod: RecipleModule, disabeVersionCheck?: boolean): ResolvedModule;
77
+ getModuleFiles(...folders: RestOrArray<string>): Promise<string[]>;
78
+ static getModuleDisplayId(mod: RecipleModule): string;
79
+ }
@@ -1,14 +1,32 @@
1
1
  import { Guild, RestOrArray, TextBasedChannel, User } from 'discord.js';
2
- import { CommandBuilderType } from '../types/builders';
2
+ import { CommandBuilderType } from '../../types/builders';
3
3
  /**
4
4
  * cooled-down user object interface
5
5
  */
6
6
  export interface CooledDownUser {
7
+ /**
8
+ * Cooled-down user
9
+ */
7
10
  user: User;
11
+ /**
12
+ * Cooled-down command name
13
+ */
8
14
  command: string;
15
+ /**
16
+ * Command type
17
+ */
9
18
  type: CommandBuilderType;
19
+ /**
20
+ * In guild
21
+ */
10
22
  guild?: Guild | null;
23
+ /**
24
+ * Cooled-down channel
25
+ */
11
26
  channel?: TextBasedChannel;
27
+ /**
28
+ * Cooldown expiration
29
+ */
12
30
  expireTime: number;
13
31
  }
14
32
  /**
@@ -25,8 +43,9 @@ export declare class CommandCooldownManager extends Array<CooledDownUser> {
25
43
  * Remove cooldown from specific user, channel or guild
26
44
  * @param options Remove cooldown data options
27
45
  * @param limit Remove cooldown data limit
46
+ * @returns Returns the removed values
28
47
  */
29
- remove(options: Partial<CooledDownUser>, limit?: number): void;
48
+ remove(options: Partial<CooledDownUser>, limit?: number): CooledDownUser[];
30
49
  /**
31
50
  * Check if the given user is cooled-down
32
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
@@ -1,26 +1,58 @@
1
1
  import { AnyCommandBuilder, AnyCommandData } from './types/builders';
2
2
  import { RecipleClient } from './classes/RecipleClient';
3
- export declare type LoadedModules = {
3
+ /**
4
+ * Loaded modules and commands
5
+ */
6
+ export interface LoadedModules {
4
7
  commands: AnyCommandBuilder[];
5
8
  modules: RecipleModule[];
6
- };
9
+ }
7
10
  /**
8
11
  * Reciple script object
9
12
  */
10
13
  export interface RecipleScript {
14
+ /**
15
+ * Supported reciple versions
16
+ */
11
17
  versions: string | string[];
18
+ /**
19
+ * Module commands
20
+ */
12
21
  commands?: (AnyCommandBuilder | AnyCommandData)[];
13
- onLoad?(client: RecipleClient): void | Promise<void>;
14
- onStart(client: RecipleClient): boolean | Promise<boolean>;
22
+ /**
23
+ * Action on bot ready
24
+ * @param client Bot client
25
+ */
26
+ onLoad?(client: RecipleClient<true>): void | Promise<void>;
27
+ /**
28
+ * Action on module start
29
+ * @param client Bot client
30
+ */
31
+ onStart(client: RecipleClient<false>): boolean | Promise<boolean>;
15
32
  }
16
33
  /**
17
34
  * Reciple module object
18
35
  */
19
36
  export interface RecipleModule {
37
+ /**
38
+ * Module script
39
+ */
20
40
  script: RecipleScript;
41
+ /**
42
+ * Module local information
43
+ */
21
44
  info: {
45
+ /**
46
+ * Module file name
47
+ */
22
48
  filename?: string;
49
+ /**
50
+ * Supported reciple versions
51
+ */
23
52
  versions: string[];
53
+ /**
54
+ * Module local file path
55
+ */
24
56
  path?: string;
25
57
  };
26
58
  }
@@ -7,11 +7,13 @@ import { UserHasCommandPermissionsOptions } from './types/paramOptions';
7
7
  export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
8
8
  /**
9
9
  * Check if the bot has the required permissions in a guild
10
- * @param guild 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
11
  * @param requiredPermissions Required guild bot permissions
12
12
  */
13
13
  export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
14
14
  /**
15
- * @param channel Check if the bot has the required permissions in a channel
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
16
18
  */
17
19
  export declare function botHasExecutePermissions(channel?: GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
@@ -5,31 +5,31 @@ import { MessageCommandOptionBuilder } from '../classes/builders/MessageCommandO
5
5
  /**
6
6
  * Any command builders
7
7
  */
8
- export declare type AnyCommandBuilder<T extends unknown = any> = AnySlashCommandBuilder<T> | MessageCommandBuilder<T>;
8
+ export declare type AnyCommandBuilder<T = unknown> = AnySlashCommandBuilder<T> | MessageCommandBuilder<T>;
9
9
  /**
10
10
  * Any command data
11
11
  */
12
- export declare type AnyCommandData<T extends unknown = any> = SlashCommandData<T> | MessageCommandData<T>;
12
+ export declare type AnyCommandData<T = unknown> = SlashCommandData<T> | MessageCommandData<T>;
13
13
  /**
14
14
  * Any slash command builders
15
15
  */
16
- export declare type AnySlashCommandBuilder<T extends unknown = any> = SlashCommandBuilder<T> | SlashCommandOptionsOnlyBuilder<T> | SlashCommandSubcommandsOnlyBuilder<T>;
16
+ export declare type AnySlashCommandBuilder<T = unknown> = SlashCommandBuilder<T> | SlashCommandOptionsOnlyBuilder<T> | SlashCommandSubcommandsOnlyBuilder<T>;
17
17
  /**
18
18
  * Any command halt functions
19
19
  */
20
- export declare type AnyCommandHaltFunction = SlashCommandHaltFunction | MessageCommandHaltFunction;
20
+ export declare type AnyCommandHaltFunction<T = unknown> = SlashCommandHaltFunction<T> | MessageCommandHaltFunction<T>;
21
21
  /**
22
22
  * Any command execute function
23
23
  */
24
- export declare type AnyCommandExecuteFunction = SlashCommandExecuteFunction | MessageCommandExecuteFunction;
24
+ export declare type AnyCommandExecuteFunction<T = unknown> = SlashCommandExecuteFunction<T> | MessageCommandExecuteFunction<T>;
25
25
  /**
26
26
  * Command halt function
27
27
  */
28
- export declare type CommandHaltFunction<T extends CommandBuilderType> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData : MessageCommandHaltData) => Awaitable<boolean | null | undefined | void>;
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>;
29
29
  /**
30
30
  * Command execute function
31
31
  */
32
- export declare type CommandExecuteFunction<T extends CommandBuilderType> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : MessageCommandExecuteData) => Awaitable<void>;
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>;
33
33
  /**
34
34
  * Message command options resolvable
35
35
  */
@@ -60,13 +60,13 @@ export declare enum CommandBuilderType {
60
60
  /**
61
61
  * Shared command builder methods and properties
62
62
  */
63
- export interface SharedCommandBuilderProperties<T extends unknown> {
63
+ export interface SharedCommandBuilderProperties<T = unknown> {
64
64
  readonly type: CommandBuilderType;
65
65
  cooldown: number;
66
66
  requiredBotPermissions: PermissionResolvable[];
67
67
  requiredMemberPermissions: PermissionResolvable[];
68
- halt?: AnyCommandHaltFunction;
69
- execute: AnyCommandExecuteFunction;
68
+ halt?: AnyCommandHaltFunction<T>;
69
+ execute: AnyCommandExecuteFunction<T>;
70
70
  metadata?: T;
71
71
  /**
72
72
  * Sets the execute cooldown for this command.
@@ -110,7 +110,7 @@ export interface SharedCommandDataProperties {
110
110
  /**
111
111
  * Slash command object data interface
112
112
  */
113
- export interface SlashCommandData<T extends unknown = any> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
113
+ export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
114
114
  type: CommandBuilderType.SlashCommand;
115
115
  nameLocalizations?: LocalizationMap;
116
116
  descriptionLocalizations?: LocalizationMap;
@@ -121,8 +121,8 @@ export interface SlashCommandData<T extends unknown = any> extends SharedCommand
121
121
  defaultPermission?: boolean;
122
122
  defaultMemberPermissions?: string | null;
123
123
  dmPermission?: boolean;
124
- halt?: SlashCommandHaltFunction;
125
- execute: SlashCommandExecuteFunction;
124
+ halt?: SlashCommandHaltFunction<T>;
125
+ execute: SlashCommandExecuteFunction<T>;
126
126
  }
127
127
  export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
128
128
  choices?: {
@@ -178,14 +178,14 @@ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProper
178
178
  /**
179
179
  * Message command object data interface
180
180
  */
181
- export interface MessageCommandData<T extends unknown = any> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
181
+ export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
182
182
  type: CommandBuilderType.MessageCommand;
183
183
  aliases?: string[];
184
184
  validateOptions?: boolean;
185
185
  allowExecuteInDM?: boolean;
186
186
  allowExecuteByBots?: boolean;
187
- halt?: MessageCommandHaltFunction;
188
- execute: MessageCommandExecuteFunction;
187
+ halt?: MessageCommandHaltFunction<T>;
188
+ execute: MessageCommandExecuteFunction<T>;
189
189
  options?: MessageCommandOptionResolvable[];
190
190
  }
191
191
  /**
@@ -1,52 +1,71 @@
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
6
  import { CommandBuilderType } from '../types/builders';
7
7
  /**
8
8
  * Any command halt data
9
9
  */
10
- export declare type AnyCommandHaltData = SlashCommandHaltData | MessageCommandHaltData;
10
+ export declare type AnyCommandHaltData<T = unknown> = SlashCommandHaltData<T> | MessageCommandHaltData<T>;
11
11
  /**
12
12
  * command halt data
13
13
  */
14
- export declare type CommandHaltData<T extends CommandBuilderType> = CommandErrorData<T> | CommandCooldownData<T> | (T extends CommandBuilderType.SlashCommand ? never : CommandInvalidArguments<T> | CommandMissingArguments<T>) | CommandMissingMemberPermissions<T> | CommandMissingBotPermissions<T>;
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>;
15
15
  /**
16
16
  * Any command execute data
17
17
  */
18
- export declare type AnyCommandExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
18
+ export declare type AnyCommandExecuteData<T = unknown> = SlashCommandExecuteData<T> | MessageCommandExecuteData<T>;
19
19
  /**
20
20
  * Command execute data
21
21
  */
22
22
  export interface BaseCommandExecuteData {
23
+ /**
24
+ * Bot client
25
+ */
23
26
  client: RecipleClient<true>;
24
27
  }
25
28
  /**
26
29
  * Command halt reason base
27
30
  */
28
- export interface BaseCommandHaltData<T extends CommandBuilderType> {
29
- executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData : AnyCommandExecuteData;
31
+ export interface BaseCommandHaltData<T extends CommandBuilderType, M = unknown> {
32
+ /**
33
+ * Halt reason
34
+ */
35
+ reason: CommandHaltReason;
36
+ /**
37
+ * Command execute da6a
38
+ */
39
+ executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData<M> : AnyCommandExecuteData<M>;
30
40
  }
31
- export interface CommandErrorData<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
41
+ export interface CommandErrorData<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
32
42
  reason: CommandHaltReason.Error;
43
+ /**
44
+ * Caught error
45
+ */
33
46
  error: any;
34
47
  }
35
- export interface CommandCooldownData<T extends CommandBuilderType> extends BaseCommandHaltData<T>, CooledDownUser {
48
+ export interface CommandCooldownData<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M>, CooledDownUser {
36
49
  reason: CommandHaltReason.Cooldown;
37
50
  }
38
- export interface CommandInvalidArguments<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
51
+ export interface CommandInvalidArguments<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
39
52
  reason: CommandHaltReason.InvalidArguments;
53
+ /**
54
+ * Arguments that are invalid
55
+ */
40
56
  invalidArguments: MessageCommandOptionManager;
41
57
  }
42
- export interface CommandMissingArguments<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
58
+ export interface CommandMissingArguments<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
43
59
  reason: CommandHaltReason.MissingArguments;
60
+ /**
61
+ * Arguments that are missing
62
+ */
44
63
  missingArguments: MessageCommandOptionManager;
45
64
  }
46
- export interface CommandMissingMemberPermissions<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
65
+ export interface CommandMissingMemberPermissions<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
47
66
  reason: CommandHaltReason.MissingMemberPermissions;
48
67
  }
49
- export interface CommandMissingBotPermissions<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
68
+ export interface CommandMissingBotPermissions<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
50
69
  reason: CommandHaltReason.MissingBotPermissions;
51
70
  }
52
71
  /**
@@ -1,8 +1,6 @@
1
- import { ApplicationCommandBuilder } from '../registerApplicationCommands';
2
- import { ApplicationCommandData, PermissionsBitField } from 'discord.js';
1
+ import { ConfigCommandPermissions } from '../classes/RecipleConfig';
3
2
  import { RecipleModule, RecipleScript } from '../modules';
4
- import { RecipleClient } from '../classes/RecipleClient';
5
- import { Config } from '../classes/RecipleConfig';
3
+ import { PermissionsBitField } from 'discord.js';
6
4
  import { AnyCommandBuilder } from './builders';
7
5
  export interface RecipleClientAddModuleOptions {
8
6
  /**
@@ -18,22 +16,25 @@ export interface RecipleClientAddModuleOptions {
18
16
  */
19
17
  moduleInfo?: RecipleModule["info"];
20
18
  }
21
- export interface RegisterApplicationCommandsOptions {
19
+ export interface UserHasCommandPermissionsOptions {
22
20
  /**
23
- * Bot client
21
+ * Command builder
24
22
  */
25
- client: RecipleClient;
23
+ builder: AnyCommandBuilder;
26
24
  /**
27
- * Commands to register
25
+ * Member permissions
28
26
  */
29
- commands: (ApplicationCommandData | ApplicationCommandBuilder)[];
30
- /**
31
- * Set guild to not register commands globally
27
+ memberPermissions?: PermissionsBitField;
28
+ /***
29
+ * Required command config permissions
32
30
  */
33
- guilds?: string | string[];
31
+ commandPermissions?: {
32
+ enabled: boolean;
33
+ commands: ConfigCommandPermissions[];
34
+ };
34
35
  }
35
- export interface UserHasCommandPermissionsOptions {
36
- builder: AnyCommandBuilder;
37
- memberPermissions?: PermissionsBitField;
38
- commandPermissions?: Config["commands"]["slashCommand"]["permissions"] | Config["commands"]["messageCommand"]["permissions"];
36
+ export interface ModuleManagerResolveFilesOptions {
37
+ files: string[];
38
+ disabeVersionCheck?: boolean;
39
+ dontSkipError?: boolean;
39
40
  }
@@ -1 +1,12 @@
1
- export declare function isClass<T extends any>(object: any): object is T;
1
+ import { AnyCommandBuilder } from './types/builders';
2
+ /**
3
+ * Check if an object is a class
4
+ * @param object Object to identify
5
+ */
6
+ export declare function isClass<T = any>(object: any): object is T;
7
+ /**
8
+ * Emit process warning about deprecated method/function
9
+ * @param content Warning content
10
+ */
11
+ export declare function deprecationWarning(content: string | Error): void;
12
+ export declare function validateCommandBuilder(command: AnyCommandBuilder): boolean;