js-discord-modularcommand 2.0.1 → 2.0.3

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.
@@ -28,9 +28,11 @@ function ModularCommandHandler(client, customHandler) {
28
28
  if (!interaction.isChatInputCommand() && !interaction.isMessageComponent() && !interaction.isModalSubmit()) {
29
29
  return;
30
30
  }
31
- const response = await customHandler({ interaction });
32
- if (response === false)
33
- return;
31
+ if (typeof customHandler === "function") {
32
+ const response = await customHandler({ interaction });
33
+ if (response === false)
34
+ return;
35
+ }
34
36
  let commandName;
35
37
  if (interaction.isChatInputCommand()) {
36
38
  commandName = interaction.commandName;
@@ -48,11 +48,14 @@ const locales_1 = require("./locales");
48
48
  * @param {ModularCommand} command The command instance.
49
49
  * @param {Interaction} interaction The interaction object to get the locale from.
50
50
  * @returns {CommandLocale} The resolved locale object.
51
- * @throws {Error} If the EnglishUS localization is missing.
51
+ * @throws {Error} If the EnglishUS localization is missing when at least one localization is defined.
52
52
  */
53
53
  function getCommandLocale(command, interaction) {
54
54
  const localeTable = command.localizationPhrases;
55
- if (!localeTable || !localeTable[discord_js_1.Locale.EnglishUS]) {
55
+ if (!localeTable || Object.keys(localeTable).length === 0) {
56
+ return {};
57
+ }
58
+ if (!localeTable[discord_js_1.Locale.EnglishUS]) {
56
59
  throw new Error(`Missing localization for EnglishUS in command ${command.name}`);
57
60
  }
58
61
  const targetLocale = localeTable[interaction.locale] ? interaction.locale : discord_js_1.Locale.EnglishUS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-discord-modularcommand",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "discord",
@@ -8,7 +8,7 @@
8
8
  "node"
9
9
  ],
10
10
  "license": "MIT",
11
- "author": "SummerTYT",
11
+ "author": "vicentefelipechile",
12
12
  "type": "commonjs",
13
13
  "types": "./dist/index.d.ts",
14
14
  "files": [