@power-bots/powerbotlibrary 0.5.5 → 0.5.6

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 (2) hide show
  1. package/dist/lib/lang.js +12 -3
  2. package/package.json +1 -1
package/dist/lib/lang.js CHANGED
@@ -21,8 +21,16 @@ const discord_js_1 = require("discord.js");
21
21
  function localize(obj, lang, args) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
23
  if (typeof obj === "string") {
24
- if (obj.startsWith("$"))
25
- return lang.get(obj.replace("$", ""), args) || obj;
24
+ if (obj.startsWith("$")) {
25
+ const spaceIndex = obj.indexOf(" ");
26
+ const endIndex = spaceIndex === -1 ? obj.length : spaceIndex;
27
+ const keyPart = obj.slice(0, endIndex);
28
+ const key = keyPart.slice(1);
29
+ const replacement = yield lang.get(key, args);
30
+ if (replacement !== undefined) {
31
+ return obj.replace(keyPart, replacement);
32
+ }
33
+ }
26
34
  return obj;
27
35
  }
28
36
  if (Array.isArray(obj)) {
@@ -51,7 +59,8 @@ function reply(interaction, text, args) {
51
59
  let flags = [];
52
60
  if ((_a = embed === null || embed === void 0 ? void 0 : embed.options) === null || _a === void 0 ? void 0 : _a.ephemeral)
53
61
  flags.push(discord_js_1.MessageFlags.Ephemeral);
54
- const newEmbed = yield localize(embed, Lang.en, args);
62
+ var newEmbed = yield localize(embed, Lang.en, args);
63
+ var newEmbed = yield localize(newEmbed, Lang.global, args);
55
64
  yield interaction.reply({ embeds: [newEmbed], flags: flags });
56
65
  });
57
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-bots/powerbotlibrary",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/main.d.ts",
6
6
  "dependencies": {