js-discord-modularcommand 1.1.0 → 2.0.0

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.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @file Contains the structure for creating reusable button components.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { ButtonBuilder, ButtonStyle } from "discord.js";
7
+ import { ButtonExecuteFunction } from "./types";
8
+ /**
9
+ * @class ModularButton
10
+ * @description A class to create and manage reusable button components.
11
+ */
12
+ export default class ModularButton {
13
+ /** The Discord.js ButtonBuilder instance. */
14
+ buttonObject: ButtonBuilder;
15
+ /** The custom ID for the button, used to identify it in interactions. */
16
+ customId: string;
17
+ /** The visual style of the button. */
18
+ style: ButtonStyle;
19
+ /** The function to execute when the button is clicked. */
20
+ execute: ButtonExecuteFunction;
21
+ /**
22
+ * @description Creates a new ModularButton instance.
23
+ * @param {string} customId The custom ID for the button. This should be unique within the context of a message.
24
+ * @param {ButtonStyle} style The visual style of the button.
25
+ */
26
+ constructor(customId: string, style: ButtonStyle);
27
+ /**
28
+ * @description Sets the execution function for the button's click event.
29
+ * @param {ButtonExecuteFunction} executeFunction The function to run when the button is interacted with.
30
+ * @returns {this} The current ModularButton instance for method chaining.
31
+ */
32
+ setExecute(executeFunction: ButtonExecuteFunction): this;
33
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * @file Contains the structure for creating reusable button components.
4
+ * @author vicentefelipechile
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const discord_js_1 = require("discord.js");
9
+ // =================================================================================================
10
+ // Main Class
11
+ // =================================================================================================
12
+ /**
13
+ * @class ModularButton
14
+ * @description A class to create and manage reusable button components.
15
+ */
16
+ class ModularButton {
17
+ /**
18
+ * @description Creates a new ModularButton instance.
19
+ * @param {string} customId The custom ID for the button. This should be unique within the context of a message.
20
+ * @param {ButtonStyle} style The visual style of the button.
21
+ */
22
+ constructor(customId, style) {
23
+ /** The function to execute when the button is clicked. */
24
+ this.execute = async () => { };
25
+ this.buttonObject = new discord_js_1.ButtonBuilder()
26
+ .setCustomId(customId)
27
+ .setStyle(style);
28
+ this.customId = customId;
29
+ this.style = style;
30
+ }
31
+ /**
32
+ * @description Sets the execution function for the button's click event.
33
+ * @param {ButtonExecuteFunction} executeFunction The function to run when the button is interacted with.
34
+ * @returns {this} The current ModularButton instance for method chaining.
35
+ */
36
+ setExecute(executeFunction) {
37
+ this.execute = executeFunction;
38
+ return this;
39
+ }
40
+ }
41
+ exports.default = ModularButton;
@@ -6,90 +6,10 @@
6
6
  /**
7
7
  * Imports
8
8
  */
9
- import { ApplicationCommandOptionType, MessageComponentInteraction, ChatInputCommandInteraction, ModalSubmitInteraction, SlashCommandBuilder, ButtonBuilder, Locale, Message, ButtonStyle, Channel, User, Role, GuildMember, LocalizationMap, APIApplicationCommandOptionChoice } from 'discord.js';
9
+ import { LocalizationMap, ButtonStyle, Locale } from 'discord.js';
10
10
  import ModularModal from './modularmodal.js';
11
- /**
12
- * Types
13
- */
14
- type ArgType = string | number | boolean | User | Channel | Role | GuildMember;
15
- type ExecuteFunction<T extends ChatInputCommandInteraction | MessageComponentInteraction> = (params: {
16
- interaction: T;
17
- args?: Record<string, ArgType>;
18
- command: ModularCommand;
19
- locale: Record<string, any>;
20
- }) => Promise<void>;
21
- type ButtonExecuteFunction = (params: {
22
- interaction: MessageComponentInteraction;
23
- command: ModularCommand;
24
- locale: Record<string, any>;
25
- message: Message;
26
- }) => Promise<void>;
27
- type ModalExecuteFunction = (params: {
28
- interaction: ModalSubmitInteraction;
29
- args: Record<string, string>;
30
- command: ModularCommand;
31
- locale: Record<string, any>;
32
- }) => Promise<void>;
33
- type PermissionCheckFunction = (params: {
34
- interaction: ChatInputCommandInteraction;
35
- }) => boolean | Promise<boolean>;
36
- /**
37
- * @description Registered Command as object to be used outside the modular command system.
38
- * @example
39
- * const PingCommand = new ModularCommand('ping');
40
- *
41
- * PingCommand.setExecute(({interaction}) => {
42
- * interaction.reply('Pong!');
43
- * });
44
- *
45
- * const cmds = RegisterCommand([PingCommand])
46
- * const cmd = cmds[0];
47
- * console.log(cmd.execute); // [Function: execute]
48
- */
49
- type RegisteredCommand = {
50
- data: SlashCommandBuilder;
51
- execute: (interaction: ChatInputCommandInteraction) => Promise<void>;
52
- componentExecute?: (interaction: MessageComponentInteraction) => Promise<void>;
53
- modalExecute?: (interaction: ModalSubmitInteraction) => Promise<void>;
54
- buttonExecute?: (interaction: MessageComponentInteraction) => Promise<void>;
55
- cooldown: number;
56
- };
57
- /**
58
- * Interface
59
- */
60
- /**
61
- * @description Represents a command option for a modular command.
62
- */
63
- interface CommandOption {
64
- name: string;
65
- type: ApplicationCommandOptionType;
66
- description: Record<Locale, string> | string;
67
- required?: boolean;
68
- choices?: APIApplicationCommandOptionChoice[];
69
- }
70
- /**
71
- * @class ModularButton
72
- * @description Represents a modular button that can be registered with Discord.js.
73
- * It allows for dynamic button creation and execution.
74
- */
75
- declare class ModularButton {
76
- buttonObject: ButtonBuilder;
77
- customId: string;
78
- style: ButtonStyle;
79
- execute: ButtonExecuteFunction;
80
- /**
81
- * Creates a new button for the command.
82
- * @param {string} customId The custom ID for the button.
83
- * @param {ButtonStyle} style The style of the button.
84
- */
85
- constructor(customId: string, style: ButtonStyle);
86
- /**
87
- * Sets the execute function for the button.
88
- * @param {ButtonExecuteFunction} executeFunction The function to execute.
89
- * @return {ModularButton} The button instance for chaining.
90
- */
91
- setExecute(executeFunction: ButtonExecuteFunction): this;
92
- }
11
+ import ModularButton from './modularbutton.js';
12
+ import { ButtonExecuteFunction, CommandExecuteFunction, CommandOption, ComponentExecuteFunction, ModalExecuteFunction, PermissionCheckFunction } from './types.js';
93
13
  /**
94
14
  * @description Represents a modular command that can be registered with Discord.js.
95
15
  * It allows for dynamic command creation and execution.
@@ -110,22 +30,23 @@ declare class ModularButton {
110
30
  * PingCommand
111
31
  * ]);
112
32
  */
113
- declare class ModularCommand {
33
+ export default class ModularCommand {
114
34
  name: string;
115
35
  description: string;
116
- execute: ExecuteFunction<ChatInputCommandInteraction>;
117
- componentExecute?: ExecuteFunction<MessageComponentInteraction>;
36
+ execute: CommandExecuteFunction;
37
+ buttonExecute?: ButtonExecuteFunction;
38
+ componentExecute?: ComponentExecuteFunction;
118
39
  modalExecute?: ModalExecuteFunction;
119
40
  options: CommandOption[];
120
41
  optionsLocalizations: Record<string, Record<Locale, string>>;
121
- customIdHandlers: Record<string, ExecuteFunction<ChatInputCommandInteraction>>;
42
+ customIdHandlers: Record<string, CommandExecuteFunction>;
122
43
  cooldown: number;
123
44
  modals: Map<string, ModularModal>;
124
45
  buttons: Map<string, ModularButton>;
125
46
  buttonsArray: ModularButton[];
126
47
  isNSFW: boolean;
127
48
  descriptionLocalizations?: LocalizationMap;
128
- localizationPhrases?: Record<Locale, any>;
49
+ localizationPhrases?: Record<Locale, string>;
129
50
  permissionCheck?: PermissionCheckFunction;
130
51
  componentId?: string;
131
52
  constructor(name: string);
@@ -144,23 +65,23 @@ declare class ModularCommand {
144
65
  setLocalizationOptions(localizations: Record<string, Record<Locale, string>>): this;
145
66
  /**
146
67
  * Sets the localization phrases for the command.
147
- * @param {Record<Locale, any>} localizationPhrases The localization phrases.
68
+ * @param {Record<Locale, string>} localizationPhrases The localization phrases.
148
69
  * @returns {ModularCommand} The command instance for chaining.
149
70
  */
150
- setLocalizationPhrases(localizationPhrases: Record<Locale, any>): this;
71
+ setLocalizationPhrases(localizationPhrases: Record<Locale, string>): this;
151
72
  /**
152
73
  * Sets the execute function for the command.
153
- * @param {ExecuteFunction<CommandInteraction>} executeFunction The function to execute.
74
+ * @param {CommandExecuteFunction} executeFunction The function to execute.
154
75
  * @returns {ModularCommand} The command instance for chaining.
155
76
  */
156
- setExecute(executeFunction: ExecuteFunction<ChatInputCommandInteraction>): this;
77
+ setExecute(executeFunction: CommandExecuteFunction): this;
157
78
  /**
158
79
  * Sets the component execute function for the command.
159
80
  * @param {string} componentId The base ID for the components.
160
- * @param {ExecuteFunction<MessageComponentInteraction>} executeFunction The function to execute for component interactions.
81
+ * @param {ComponentExecuteFunction} executeFunction The function to execute for component interactions.
161
82
  * @returns {ModularCommand} The command instance for chaining.
162
83
  */
163
- setComponentExecute(componentId: string, executeFunction: ExecuteFunction<MessageComponentInteraction>): this;
84
+ setComponentExecute(componentId: string, executeFunction: ComponentExecuteFunction): this;
164
85
  /**
165
86
  * Set the minimun permissions required to execute the command.
166
87
  * @param {PermissionCheckFunction} permissionCheckFunction The function to check permissions.
@@ -187,10 +108,10 @@ declare class ModularCommand {
187
108
  /**
188
109
  * Adds a custom ID handler for the command.
189
110
  * @param {string} customId The custom ID to match.
190
- * @param {ExecuteFunction<CommandInteraction<CacheType>>} handlerFunction The function to execute when the custom ID matches.
111
+ * @param {CommandInteraction<CacheType>} handlerFunction The function to execute when the custom ID matches.
191
112
  * @returns {ModularCommand} The command instance for chaining.
192
113
  */
193
- addCustomIDHandler(customId: string, handlerFunction: ExecuteFunction<ChatInputCommandInteraction>): this;
114
+ addCustomIDHandler(customId: string, handlerFunction: CommandExecuteFunction): this;
194
115
  /**
195
116
  * Creates a new modal for the command.
196
117
  * @param {string} modalId The ID for the modal.
@@ -205,11 +126,3 @@ declare class ModularCommand {
205
126
  */
206
127
  addButton(customId: string, style: ButtonStyle): ModularButton;
207
128
  }
208
- /**
209
- * Registers an array of modular commands.
210
- * @param {ModularCommand[]} commands An array of ModularCommand instances.
211
- * @returns {RegisteredCommand[]} An array of command data objects ready for Discord.js client.
212
- */
213
- declare const RegisterCommand: (commands: ModularCommand[]) => RegisteredCommand[];
214
- export default ModularCommand;
215
- export { RegisterCommand, ModularCommand, ModularButton, };
@@ -8,14 +8,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ModularButton = exports.ModularCommand = exports.RegisterCommand = void 0;
12
11
  /**
13
12
  * Imports
14
13
  */
15
14
  const discord_js_1 = require("discord.js");
16
- const locales_js_1 = require("./locales.js");
17
- const locales_js_2 = require("./locales.js");
18
15
  const modularmodal_js_1 = __importDefault(require("./modularmodal.js"));
16
+ const modularbutton_js_1 = __importDefault(require("./modularbutton.js"));
17
+ /**
18
+ * Interface
19
+ */
20
+ /**
21
+ * @description Represents a command option for a modular command.
22
+ */
19
23
  /**
20
24
  * Variables
21
25
  */
@@ -27,37 +31,6 @@ const ALLOWED_OPTION_TYPE = [
27
31
  discord_js_1.ApplicationCommandOptionType.User,
28
32
  discord_js_1.ApplicationCommandOptionType.Channel,
29
33
  ];
30
- const COOLDOWNS_MAP = new Map();
31
- /**
32
- * @class ModularButton
33
- * @description Represents a modular button that can be registered with Discord.js.
34
- * It allows for dynamic button creation and execution.
35
- */
36
- class ModularButton {
37
- /**
38
- * Creates a new button for the command.
39
- * @param {string} customId The custom ID for the button.
40
- * @param {ButtonStyle} style The style of the button.
41
- */
42
- constructor(customId, style) {
43
- this.execute = async () => { };
44
- this.buttonObject = new discord_js_1.ButtonBuilder();
45
- this.buttonObject.setCustomId(customId);
46
- this.buttonObject.setStyle(style);
47
- this.customId = customId;
48
- this.style = style;
49
- }
50
- /**
51
- * Sets the execute function for the button.
52
- * @param {ButtonExecuteFunction} executeFunction The function to execute.
53
- * @return {ModularButton} The button instance for chaining.
54
- */
55
- setExecute(executeFunction) {
56
- this.execute = executeFunction;
57
- return this;
58
- }
59
- }
60
- exports.ModularButton = ModularButton;
61
34
  /**
62
35
  * @description Represents a modular command that can be registered with Discord.js.
63
36
  * It allows for dynamic command creation and execution.
@@ -119,7 +92,7 @@ class ModularCommand {
119
92
  }
120
93
  /**
121
94
  * Sets the localization phrases for the command.
122
- * @param {Record<Locale, any>} localizationPhrases The localization phrases.
95
+ * @param {Record<Locale, string>} localizationPhrases The localization phrases.
123
96
  * @returns {ModularCommand} The command instance for chaining.
124
97
  */
125
98
  setLocalizationPhrases(localizationPhrases) {
@@ -128,7 +101,7 @@ class ModularCommand {
128
101
  }
129
102
  /**
130
103
  * Sets the execute function for the command.
131
- * @param {ExecuteFunction<CommandInteraction>} executeFunction The function to execute.
104
+ * @param {CommandExecuteFunction} executeFunction The function to execute.
132
105
  * @returns {ModularCommand} The command instance for chaining.
133
106
  */
134
107
  setExecute(executeFunction) {
@@ -138,7 +111,7 @@ class ModularCommand {
138
111
  /**
139
112
  * Sets the component execute function for the command.
140
113
  * @param {string} componentId The base ID for the components.
141
- * @param {ExecuteFunction<MessageComponentInteraction>} executeFunction The function to execute for component interactions.
114
+ * @param {ComponentExecuteFunction} executeFunction The function to execute for component interactions.
142
115
  * @returns {ModularCommand} The command instance for chaining.
143
116
  */
144
117
  setComponentExecute(componentId, executeFunction) {
@@ -186,7 +159,7 @@ class ModularCommand {
186
159
  /**
187
160
  * Adds a custom ID handler for the command.
188
161
  * @param {string} customId The custom ID to match.
189
- * @param {ExecuteFunction<CommandInteraction<CacheType>>} handlerFunction The function to execute when the custom ID matches.
162
+ * @param {CommandInteraction<CacheType>} handlerFunction The function to execute when the custom ID matches.
190
163
  * @returns {ModularCommand} The command instance for chaining.
191
164
  */
192
165
  addCustomIDHandler(customId, handlerFunction) {
@@ -210,205 +183,10 @@ class ModularCommand {
210
183
  * @return {ModularButton} The created button instance.
211
184
  */
212
185
  addButton(customId, style) {
213
- const button = new ModularButton(customId, style);
186
+ const button = new modularbutton_js_1.default(customId, style);
214
187
  this.buttons.set(customId, button);
215
188
  this.buttonsArray.push(button);
216
189
  return button;
217
190
  }
218
191
  }
219
- exports.ModularCommand = ModularCommand;
220
- /**
221
- * Registers an array of modular commands.
222
- * @param {ModularCommand[]} commands An array of ModularCommand instances.
223
- * @returns {RegisteredCommand[]} An array of command data objects ready for Discord.js client.
224
- */
225
- const RegisterCommand = (commands) => {
226
- return commands.map(command => {
227
- const commandBuilder = new discord_js_1.SlashCommandBuilder()
228
- .setName(command.name)
229
- .setDescription(command.description)
230
- .setDescriptionLocalizations(command.descriptionLocalizations || null);
231
- COOLDOWNS_MAP.set(command.name, new Map());
232
- const options = {};
233
- command.options.forEach(opt => {
234
- const description = typeof opt.description === 'string' ?
235
- opt.description :
236
- (opt.description[discord_js_1.Locale.EnglishUS] || `The description for ${opt.name} in English.`);
237
- const descriptionsLocalizations = typeof opt.description === 'object' ? opt.description : {};
238
- if (!description) {
239
- throw new Error(`Option '${opt.name}' is missing a description.`);
240
- }
241
- options[opt.name] = opt.type;
242
- const optionBuilder = (option) => {
243
- option.setName(opt.name)
244
- .setDescription(description)
245
- .setRequired(opt.required || false)
246
- .setDescriptionLocalizations(descriptionsLocalizations);
247
- if (opt.choices && opt.choices.length > 0) {
248
- option.addChoices(...opt.choices);
249
- }
250
- return option;
251
- };
252
- switch (opt.type) {
253
- case discord_js_1.ApplicationCommandOptionType.String:
254
- commandBuilder.addStringOption(optionBuilder);
255
- break;
256
- case discord_js_1.ApplicationCommandOptionType.Boolean:
257
- commandBuilder.addBooleanOption(optionBuilder);
258
- break;
259
- case discord_js_1.ApplicationCommandOptionType.Integer:
260
- commandBuilder.addIntegerOption(optionBuilder);
261
- break;
262
- case discord_js_1.ApplicationCommandOptionType.Number:
263
- commandBuilder.addNumberOption(optionBuilder);
264
- break;
265
- case discord_js_1.ApplicationCommandOptionType.User:
266
- commandBuilder.addUserOption(optionBuilder);
267
- break;
268
- case discord_js_1.ApplicationCommandOptionType.Channel:
269
- commandBuilder.addChannelOption(optionBuilder);
270
- break;
271
- default:
272
- throw new Error(`Unsupported option type: ${opt.type}`);
273
- }
274
- });
275
- const executeBuilder = async (interaction) => {
276
- // User has permissions
277
- if (command.permissionCheck && !command.permissionCheck({ interaction })) {
278
- await interaction.reply({
279
- content: locales_js_1.LOCALE_FORBIDDEN[interaction.locale],
280
- flags: discord_js_1.MessageFlags.Ephemeral,
281
- });
282
- return;
283
- }
284
- // User is using a NSFW command in a non-NSFW channel
285
- if (command.isNSFW && (!interaction.channel || !('nsfw' in interaction.channel) || !interaction.channel.nsfw)) {
286
- await interaction.reply({
287
- content: locales_js_1.LOCALE_NSFW[interaction.locale],
288
- flags: discord_js_1.MessageFlags.Ephemeral,
289
- });
290
- return;
291
- }
292
- // User is in a cooldown
293
- const lastTime = COOLDOWNS_MAP.get(command.name)?.get(interaction.user.id);
294
- if (lastTime) {
295
- const cooldownDuration = (Date.now() / 1000) - lastTime;
296
- if (cooldownDuration < command.cooldown) {
297
- await interaction.reply({
298
- content: (0, locales_js_2.FormatSecondsLocale)(locales_js_1.LOCALE_DELAY[interaction.locale], command.cooldown - cooldownDuration),
299
- flags: discord_js_1.MessageFlags.Ephemeral,
300
- });
301
- return;
302
- }
303
- COOLDOWNS_MAP.get(command.name)?.set(interaction.user.id, Date.now() / 1000);
304
- }
305
- const args = {};
306
- for (const option of Object.keys(options)) {
307
- switch (options[option]) {
308
- case discord_js_1.ApplicationCommandOptionType.String:
309
- args[option] = interaction.options.getString(option, false);
310
- break;
311
- case discord_js_1.ApplicationCommandOptionType.Boolean:
312
- args[option] = interaction.options.getBoolean(option, false);
313
- break;
314
- case discord_js_1.ApplicationCommandOptionType.Integer:
315
- args[option] = interaction.options.getInteger(option, false);
316
- break;
317
- case discord_js_1.ApplicationCommandOptionType.Number:
318
- args[option] = interaction.options.getNumber(option, false);
319
- break;
320
- case discord_js_1.ApplicationCommandOptionType.User:
321
- args[option] = interaction.options.getUser(option, false);
322
- break;
323
- case discord_js_1.ApplicationCommandOptionType.Channel:
324
- args[option] = interaction.options.getChannel(option, false);
325
- break;
326
- default:
327
- throw new Error(`Unsupported option type: ${options[option]}`);
328
- }
329
- }
330
- const localeTarget = (command.localizationPhrases && command.localizationPhrases[interaction.locale])
331
- ? interaction.locale
332
- : discord_js_1.Locale.EnglishUS;
333
- const localeTable = command.localizationPhrases;
334
- const customId = interaction.customId;
335
- if (customId && command.customIdHandlers[customId]) {
336
- await command.customIdHandlers[customId]({
337
- interaction,
338
- args,
339
- command,
340
- locale: localeTable ? localeTable[localeTarget] : {},
341
- });
342
- }
343
- else {
344
- await command.execute({
345
- interaction,
346
- args,
347
- command,
348
- locale: localeTable ? localeTable[localeTarget] : {},
349
- });
350
- }
351
- };
352
- const componentExecuteBuilder = async (interaction) => {
353
- if (!command.componentExecute)
354
- return;
355
- if (!interaction.customId.startsWith(command.getComponentId()))
356
- return;
357
- const localeTarget = (command.localizationPhrases && command.localizationPhrases[interaction.locale])
358
- ? interaction.locale
359
- : discord_js_1.Locale.EnglishUS;
360
- const localeTable = command.localizationPhrases;
361
- await command.componentExecute({
362
- interaction,
363
- command,
364
- locale: localeTable ? localeTable[localeTarget] : {},
365
- });
366
- };
367
- const modalExecuteBuilder = async (interaction) => {
368
- const modalId = interaction.customId;
369
- const modalObject = command.modals.get(modalId);
370
- if (!modalObject)
371
- return;
372
- const args = {};
373
- for (const [id] of modalObject.modalInputs.entries()) {
374
- args[id] = interaction.fields.getTextInputValue(id);
375
- }
376
- const localeTarget = (command.localizationPhrases && command.localizationPhrases[interaction.locale])
377
- ? interaction.locale
378
- : discord_js_1.Locale.EnglishUS;
379
- const localeTable = command.localizationPhrases;
380
- await modalObject.execute({
381
- interaction,
382
- args,
383
- command,
384
- locale: localeTable ? localeTable[localeTarget] : {},
385
- });
386
- };
387
- const buttonExecuteBuilder = async (interaction) => {
388
- const buttonId = interaction.customId;
389
- const buttonObject = command.buttons.get(buttonId);
390
- if (!buttonObject)
391
- return;
392
- const localeTarget = (command.localizationPhrases && command.localizationPhrases[interaction.locale])
393
- ? interaction.locale
394
- : discord_js_1.Locale.EnglishUS;
395
- const localeTable = command.localizationPhrases;
396
- await buttonObject.execute({
397
- interaction,
398
- command,
399
- locale: localeTable ? localeTable[localeTarget] : {},
400
- message: interaction.message,
401
- });
402
- };
403
- return {
404
- data: commandBuilder,
405
- execute: executeBuilder,
406
- componentExecute: command.componentExecute ? componentExecuteBuilder : undefined,
407
- modalExecute: command.modals.size > 0 ? modalExecuteBuilder : undefined,
408
- buttonExecute: command.buttons.size > 0 ? buttonExecuteBuilder : undefined,
409
- cooldown: command.cooldown,
410
- };
411
- });
412
- };
413
- exports.RegisterCommand = RegisterCommand;
414
192
  exports.default = ModularCommand;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @module ModularLocale
3
+ * @description Generic localization phrases used throughout the application.
4
+ * @license MIT
5
+ */
6
+ import { Locale } from "discord.js";
7
+ /**
8
+ * @description Class to handle localization in a modular way.
9
+ */
10
+ declare class ModularLocale {
11
+ locale: Locale;
12
+ phrases: Record<string, string>;
13
+ seconds: Record<string, string>;
14
+ minutes: Record<string, string>;
15
+ constructor(locale: Locale);
16
+ /**
17
+ * Set the singular and plural forms for seconds.
18
+ * @param {string} singular The singular form (e.g., '{s} segundo').
19
+ * @param {string} plural The plural form (e.g., '{s} segundos').
20
+ * @returns {ModularLocale}
21
+ */
22
+ setSeconds(singular: string, plural: string): this;
23
+ /**
24
+ * Set the singular and plural forms for minutes.
25
+ * @param {string} singular The singular form (e.g., '{m} minuto').
26
+ * @param {string} plural The plural form (e.g., '{m} minutos').
27
+ * @returns {ModularLocale}
28
+ */
29
+ setMinutes(singular: string, plural: string): this;
30
+ /**
31
+ * Set the main phrase for the command delay.
32
+ * @param {string} phrase The phrase when only seconds or minutes are present.
33
+ * @returns {ModularLocale}
34
+ */
35
+ setPhrase(phrase: string): this;
36
+ /**
37
+ * Set the phrase when both seconds and minutes are present.
38
+ * @param {string} phrase The phrase for combined time.
39
+ * @returns {ModularLocale}
40
+ */
41
+ setPhrasePlural(phrase: string): this;
42
+ /**
43
+ * Set the phrase when only minutes are present.
44
+ * @param {string} phrase The phrase for when only minutes are present.
45
+ * @returns {ModularLocale}
46
+ */
47
+ setPhraseOnlyMinutes(phrase: string): this;
48
+ getPhrase: () => Record<string, string>;
49
+ getSeconds: () => Record<string, string>;
50
+ getMinutes: () => Record<string, string>;
51
+ /**
52
+ * Get the formatted phrase based on the time.
53
+ * @param {number} time The time in seconds.
54
+ * @returns {string} The formatted string.
55
+ */
56
+ formatTime(time: number): string;
57
+ }
58
+ /**
59
+ * @description Localization phrases for delay commands in ModularLocale structure.
60
+ * @example ```js
61
+ * const phrase = LOCALE_DELAY[Locale.EnglishUS];
62
+ * console.log( phrase.formatTime(64) ); // 'You must wait 4 seconds and 1 minute.'
63
+ * console.log( phrase.formatTime(390) ); // 'You must wait 30 seconds and 6 minutes.'
64
+ * console.log( phrase.formatTime(1) ); // 'You must wait 1 second.'
65
+ * console.log( phrase.formatTime(120) ); // 'You must wait 2 minutes.'
66
+ * ```
67
+ */
68
+ declare const LOCALE_DELAY: {
69
+ "es-419": ModularLocale;
70
+ "en-US": ModularLocale;
71
+ "en-GB": ModularLocale;
72
+ "es-ES": ModularLocale;
73
+ "pt-BR": ModularLocale;
74
+ fr: ModularLocale;
75
+ de: ModularLocale;
76
+ it: ModularLocale;
77
+ ru: ModularLocale;
78
+ "zh-CN": ModularLocale;
79
+ "zh-TW": ModularLocale;
80
+ ja: ModularLocale;
81
+ ko: ModularLocale;
82
+ bg: ModularLocale;
83
+ cs: ModularLocale;
84
+ da: ModularLocale;
85
+ nl: ModularLocale;
86
+ fi: ModularLocale;
87
+ hu: ModularLocale;
88
+ no: ModularLocale;
89
+ pl: ModularLocale;
90
+ ro: ModularLocale;
91
+ "sv-SE": ModularLocale;
92
+ tr: ModularLocale;
93
+ uk: ModularLocale;
94
+ hi: ModularLocale;
95
+ id: ModularLocale;
96
+ el: ModularLocale;
97
+ hr: ModularLocale;
98
+ lt: ModularLocale;
99
+ th: ModularLocale;
100
+ vi: ModularLocale;
101
+ };
102
+ export default LOCALE_DELAY;
103
+ export { LOCALE_DELAY, ModularLocale };