reciple 6.0.0-dev.1 → 6.0.0-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/lib/bin.mjs +53 -0
  2. package/dist/lib/esm.mjs +1 -0
  3. package/dist/{cjs → lib}/index.js +18 -18
  4. package/dist/{cjs → lib}/reciple/classes/RecipleClient.js +88 -47
  5. package/dist/{cjs → lib}/reciple/classes/RecipleConfig.js +13 -6
  6. package/dist/lib/reciple/classes/RecipleModule.js +94 -0
  7. package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandBuilder.js +6 -4
  8. package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandOptionBuilder.js +0 -0
  9. package/dist/{cjs → lib}/reciple/classes/builders/SlashCommandBuilder.js +12 -23
  10. package/dist/{cjs → lib}/reciple/classes/managers/ApplicationCommandManager.js +32 -33
  11. package/dist/{cjs → lib}/reciple/classes/managers/ClientCommandManager.js +14 -14
  12. package/dist/lib/reciple/classes/managers/ClientModuleManager.js +144 -0
  13. package/dist/{cjs → lib}/reciple/classes/managers/CommandCooldownManager.js +7 -1
  14. package/dist/{cjs → lib}/reciple/classes/managers/MessageCommandOptionManager.js +0 -0
  15. package/dist/{cjs → lib}/reciple/flags.js +2 -2
  16. package/dist/{cjs → lib}/reciple/permissions.js +3 -4
  17. package/dist/lib/reciple/types/builders.js +11 -0
  18. package/dist/{cjs → lib}/reciple/types/commands.js +0 -0
  19. package/dist/{cjs → lib}/reciple/types/paramOptions.js +0 -0
  20. package/dist/lib/reciple/util.js +66 -0
  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 -18
  25. package/dist/types/reciple/classes/RecipleClient.d.ts +3 -6
  26. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -0
  27. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +6 -6
  28. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +17 -17
  29. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +6 -11
  30. package/dist/types/reciple/classes/managers/ClientCommandManager.d.ts +3 -3
  31. package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +11 -71
  32. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +2 -2
  33. package/dist/types/reciple/types/builders.d.ts +19 -19
  34. package/dist/types/reciple/types/commands.d.ts +10 -10
  35. package/dist/types/reciple/types/paramOptions.d.ts +7 -17
  36. package/dist/types/reciple/util.d.ts +8 -0
  37. package/package.json +28 -18
  38. package/dist/cjs/bin.js +0 -50
  39. package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +0 -189
  40. package/dist/cjs/reciple/logger.js +0 -35
  41. package/dist/cjs/reciple/modules.js +0 -113
  42. package/dist/cjs/reciple/types/builders.js +0 -11
  43. package/dist/cjs/reciple/util.js +0 -32
  44. package/dist/types/reciple/logger.d.ts +0 -8
  45. package/dist/types/reciple/modules.d.ts +0 -64
  46. package/docs/README.md +0 -1
@@ -1,13 +1,13 @@
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
4
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
4
5
  import { CommandCooldownManager } from './managers/CommandCooldownManager';
5
6
  import { ApplicationCommandManager } from './managers/ApplicationCommandManager';
6
7
  import { ClientCommandManager } from './managers/ClientCommandManager';
8
+ import { ClientModuleManager } from './managers/ClientModuleManager';
7
9
  import { Config } from './RecipleConfig';
8
10
  import { Logger } from 'fallout-utility';
9
- import { Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
10
- import { ClientModuleManager } from './managers/ClientModuleManager';
11
11
  /**
12
12
  * Options for {@link RecipleClient}
13
13
  */
@@ -47,6 +47,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
47
47
  readonly modules: ClientModuleManager;
48
48
  readonly logger: Logger;
49
49
  readonly version: string;
50
+ get isClientLogsSilent(): boolean;
50
51
  /**
51
52
  * @param options Client options
52
53
  */
@@ -72,10 +73,6 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
72
73
  * @param defaultMessage Default message when the key does not exists
73
74
  */
74
75
  getConfigMessage<T = unknown>(messageKey: string, defaultMessage?: T): T;
75
- /**
76
- * Returns true if client logs is enabled
77
- */
78
- isClientLogsEnabled(): boolean;
79
76
  /**
80
77
  * Emits the {@link RecipleClientEvents["recipleReplyError"]} event
81
78
  * @param error 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,4 +1,4 @@
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
4
  import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
@@ -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;
@@ -1,20 +1,15 @@
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;
12
7
  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;
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;
18
13
  fetch(commandId: string, guild?: GuildResolvable): Promise<ApplicationCommand>;
19
14
  protected parseCommands(commands: (ApplicationCommandData | ApplicationCommandBuilder | RESTPostAPIApplicationCommandsJSONBody)[], setPermissions?: boolean): (ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody)[];
20
15
  }
@@ -1,5 +1,5 @@
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';
@@ -27,8 +27,8 @@ export declare class ClientCommandManager {
27
27
  * @param type Command type
28
28
  */
29
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;
30
+ get(command: string, type?: CommandType.MessageCommand): MessageCommandBuilder | undefined;
31
+ get(command: string, type?: CommandType.SlashCommand): SlashCommandBuilder | undefined;
32
32
  /**
33
33
  * Register application commands
34
34
  * @param guilds Register application commands to guilds
@@ -1,79 +1,19 @@
1
- import { Collection, GuildResolvable, RestOrArray } from 'discord.js';
2
- import { AnyCommandBuilder, AnyCommandData } from '../../types/builders';
3
- import { ModuleManagerResolveFilesOptions } from '../../types/paramOptions';
1
+ import { Collection } from 'discord.js';
2
+ import { ClientModuleManagerGetModulePathsOptions, ClientModuleManagerGetModulesFromFilesOptions } from '../../types/paramOptions';
4
3
  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
- }
4
+ import { RecipleModule, RecipleScript } from '../RecipleModule';
61
5
  export interface ClientModuleManagerOptions {
62
6
  client: RecipleClient;
63
- modules?: (RecipleModule & {
64
- id?: string;
65
- })[];
7
+ modules?: (RecipleModule | RecipleScript)[];
66
8
  }
67
9
  export declare class ClientModuleManager {
68
10
  readonly client: RecipleClient;
69
- readonly modules: Collection<string, ResolvedModule>;
11
+ readonly modules: Collection<string, RecipleModule>;
70
12
  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;
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
+ getModulePaths(options?: ClientModuleManagerGetModulePathsOptions): Promise<string[]>;
79
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
  */
@@ -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;
@@ -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> = 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
  /**
@@ -1,21 +1,6 @@
1
1
  import { ConfigCommandPermissions } from '../classes/RecipleConfig';
2
- import { RecipleModule, RecipleScript } from '../modules';
3
- import { PermissionsBitField } from 'discord.js';
2
+ import { Awaitable, PermissionsBitField } from 'discord.js';
4
3
  import { AnyCommandBuilder } from './builders';
5
- export interface RecipleClientAddModuleOptions {
6
- /**
7
- * The module script
8
- */
9
- script: RecipleScript;
10
- /**
11
- * Register application commands if possible
12
- */
13
- registerApplicationCommands?: boolean;
14
- /**
15
- * Module optional info
16
- */
17
- moduleInfo?: RecipleModule["info"];
18
- }
19
4
  export interface UserHasCommandPermissionsOptions {
20
5
  /**
21
6
  * Command builder
@@ -33,8 +18,13 @@ export interface UserHasCommandPermissionsOptions {
33
18
  commands: ConfigCommandPermissions[];
34
19
  };
35
20
  }
36
- export interface ModuleManagerResolveFilesOptions {
21
+ export interface ClientModuleManagerGetModulesFromFilesOptions {
37
22
  files: string[];
38
23
  disabeVersionCheck?: boolean;
39
24
  dontSkipError?: boolean;
40
25
  }
26
+ export interface ClientModuleManagerGetModulePathsOptions {
27
+ folders?: string[];
28
+ ignoredFiles?: string[];
29
+ filter?: (file: string) => Awaitable<boolean>;
30
+ }
@@ -1,3 +1,4 @@
1
+ import { Logger } from 'fallout-utility';
1
2
  import { AnyCommandBuilder } from './types/builders';
2
3
  /**
3
4
  * Check if an object is a class
@@ -10,3 +11,10 @@ export declare function isClass<T = any>(object: any): object is T;
10
11
  */
11
12
  export declare function deprecationWarning(content: string | Error): void;
12
13
  export declare function validateCommandBuilder(command: AnyCommandBuilder): boolean;
14
+ /**
15
+ * Create new logger
16
+ * @param stringifyJSON stringify json objects in console
17
+ * @param debugmode display debug messages
18
+ * @param colorizeMessage add logger colours to messages
19
+ */
20
+ export declare function createLogger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;