js-discord-modularcommand 1.1.0 → 2.0.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.
- package/dist/cooldown.d.ts +44 -0
- package/dist/cooldown.js +81 -0
- package/dist/index.d.ts +8 -11
- package/dist/index.js +14 -9
- package/dist/interaction.d.ts +29 -0
- package/dist/interaction.js +83 -0
- package/dist/loadcommands.d.ts +27 -0
- package/dist/loadcommands.js +40 -0
- package/dist/locales.d.ts +8 -39
- package/dist/locales.js +47 -135
- package/dist/modularbutton.d.ts +33 -0
- package/dist/modularbutton.js +41 -0
- package/dist/modularcommand.d.ts +54 -121
- package/dist/modularcommand.js +26 -260
- package/dist/modularlocale.d.ts +103 -0
- package/dist/modularlocale.js +320 -0
- package/dist/modularmodal.d.ts +26 -41
- package/dist/modularmodal.js +37 -44
- package/dist/registercommand.d.ts +14 -0
- package/dist/registercommand.js +249 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.js +23 -0
- package/package.json +12 -3
package/dist/modularcommand.js
CHANGED
|
@@ -1,81 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* @
|
|
3
|
+
* @file Contains the main class for creating modular commands.
|
|
4
|
+
* @author vicentefelipechile
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
11
|
+
// =================================================================================================
|
|
12
|
+
// Imports
|
|
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"));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
discord_js_1.ApplicationCommandOptionType.String,
|
|
24
|
-
discord_js_1.ApplicationCommandOptionType.Boolean,
|
|
25
|
-
discord_js_1.ApplicationCommandOptionType.Integer,
|
|
26
|
-
discord_js_1.ApplicationCommandOptionType.Number,
|
|
27
|
-
discord_js_1.ApplicationCommandOptionType.User,
|
|
28
|
-
discord_js_1.ApplicationCommandOptionType.Channel,
|
|
29
|
-
];
|
|
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;
|
|
16
|
+
const modularbutton_js_1 = __importDefault(require("./modularbutton.js"));
|
|
17
|
+
// =================================================================================================
|
|
18
|
+
// Class: ModularCommand
|
|
19
|
+
// =================================================================================================
|
|
61
20
|
/**
|
|
62
21
|
* @description Represents a modular command that can be registered with Discord.js.
|
|
63
|
-
* It allows for dynamic command creation and execution.
|
|
22
|
+
* It allows for dynamic command creation and execution in a simple way.
|
|
64
23
|
* @example
|
|
65
24
|
* const { ModularCommand, RegisterCommand } = require('js-discord-modularcommand');
|
|
66
25
|
*
|
|
67
26
|
* const PingCommand = new ModularCommand('ping');
|
|
68
27
|
* PingCommand.setDescription('Sends a ping message.');
|
|
69
28
|
* PingCommand.setExecute(async ({interaction}) => {
|
|
70
|
-
*
|
|
29
|
+
* await interaction.reply('Pong!');
|
|
71
30
|
* });
|
|
72
31
|
*
|
|
73
32
|
* PingCommand.setPermissionCheck(({ interaction }) => {
|
|
74
|
-
*
|
|
33
|
+
* return interaction.member.permissions.has(PermissionFlagsBits.Administrator);
|
|
75
34
|
* });
|
|
76
35
|
*
|
|
77
36
|
* module.exports = RegisterCommand([
|
|
78
|
-
*
|
|
37
|
+
* PingCommand
|
|
79
38
|
* ]);
|
|
80
39
|
*/
|
|
81
40
|
class ModularCommand {
|
|
@@ -105,7 +64,7 @@ class ModularCommand {
|
|
|
105
64
|
}
|
|
106
65
|
/**
|
|
107
66
|
* Sets the description localizations for the command.
|
|
108
|
-
* @param {LocalizationMap} localizations The description localizations.
|
|
67
|
+
* @param {LocalizationMap} localizations The description localizations map.
|
|
109
68
|
* @returns {ModularCommand} The command instance for chaining.
|
|
110
69
|
*/
|
|
111
70
|
setLocalizationsDescription(localizations) {
|
|
@@ -113,13 +72,18 @@ class ModularCommand {
|
|
|
113
72
|
this.descriptionLocalizations = localizations;
|
|
114
73
|
return this;
|
|
115
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Sets the localizations for the command's options.
|
|
77
|
+
* @param {Record<string, Record<Locale, string>>} localizations An object with the localizations.
|
|
78
|
+
* @returns {ModularCommand} The command instance for chaining.
|
|
79
|
+
*/
|
|
116
80
|
setLocalizationOptions(localizations) {
|
|
117
81
|
this.optionsLocalizations = localizations;
|
|
118
82
|
return this;
|
|
119
83
|
}
|
|
120
84
|
/**
|
|
121
85
|
* Sets the localization phrases for the command.
|
|
122
|
-
* @param {Record<Locale,
|
|
86
|
+
* @param {Record<Locale, string>} localizationPhrases The localization phrases.
|
|
123
87
|
* @returns {ModularCommand} The command instance for chaining.
|
|
124
88
|
*/
|
|
125
89
|
setLocalizationPhrases(localizationPhrases) {
|
|
@@ -128,7 +92,7 @@ class ModularCommand {
|
|
|
128
92
|
}
|
|
129
93
|
/**
|
|
130
94
|
* Sets the execute function for the command.
|
|
131
|
-
* @param {
|
|
95
|
+
* @param {CommandExecuteFunction} executeFunction The function to execute.
|
|
132
96
|
* @returns {ModularCommand} The command instance for chaining.
|
|
133
97
|
*/
|
|
134
98
|
setExecute(executeFunction) {
|
|
@@ -138,7 +102,7 @@ class ModularCommand {
|
|
|
138
102
|
/**
|
|
139
103
|
* Sets the component execute function for the command.
|
|
140
104
|
* @param {string} componentId The base ID for the components.
|
|
141
|
-
* @param {
|
|
105
|
+
* @param {ComponentExecuteFunction} executeFunction The function to execute for component interactions.
|
|
142
106
|
* @returns {ModularCommand} The command instance for chaining.
|
|
143
107
|
*/
|
|
144
108
|
setComponentExecute(componentId, executeFunction) {
|
|
@@ -147,7 +111,7 @@ class ModularCommand {
|
|
|
147
111
|
return this;
|
|
148
112
|
}
|
|
149
113
|
/**
|
|
150
|
-
*
|
|
114
|
+
* Sets the minimum permissions required to execute the command.
|
|
151
115
|
* @param {PermissionCheckFunction} permissionCheckFunction The function to check permissions.
|
|
152
116
|
* @returns {ModularCommand} The command instance for chaining.
|
|
153
117
|
*/
|
|
@@ -173,20 +137,17 @@ class ModularCommand {
|
|
|
173
137
|
}
|
|
174
138
|
/**
|
|
175
139
|
* Adds an option to the command.
|
|
176
|
-
* @param {CommandOption} option The option for the command
|
|
140
|
+
* @param {CommandOption} option The option for the command.
|
|
177
141
|
* @returns {ModularCommand} The command instance for chaining.
|
|
178
142
|
*/
|
|
179
143
|
addOption(option) {
|
|
180
|
-
if (!ALLOWED_OPTION_TYPE.includes(option.type)) {
|
|
181
|
-
throw new Error(`Invalid option type: ${option.type}. Allowed types are: ${ALLOWED_OPTION_TYPE.join(', ')}`);
|
|
182
|
-
}
|
|
183
144
|
this.options.push(option);
|
|
184
145
|
return this;
|
|
185
146
|
}
|
|
186
147
|
/**
|
|
187
148
|
* Adds a custom ID handler for the command.
|
|
188
149
|
* @param {string} customId The custom ID to match.
|
|
189
|
-
* @param {
|
|
150
|
+
* @param {CommandExecuteFunction} handlerFunction The function to execute when the custom ID matches.
|
|
190
151
|
* @returns {ModularCommand} The command instance for chaining.
|
|
191
152
|
*/
|
|
192
153
|
addCustomIDHandler(customId, handlerFunction) {
|
|
@@ -210,205 +171,10 @@ class ModularCommand {
|
|
|
210
171
|
* @return {ModularButton} The created button instance.
|
|
211
172
|
*/
|
|
212
173
|
addButton(customId, style) {
|
|
213
|
-
const button = new
|
|
174
|
+
const button = new modularbutton_js_1.default(customId, style);
|
|
214
175
|
this.buttons.set(customId, button);
|
|
215
176
|
this.buttonsArray.push(button);
|
|
216
177
|
return button;
|
|
217
178
|
}
|
|
218
179
|
}
|
|
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
180
|
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 };
|