@power-bots/powerbotlibrary 0.5.4 → 0.5.5

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.
@@ -18,8 +18,6 @@ module.exports = {
18
18
  execute(interaction) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  var _a, _b, _c, _d, _e, _f, _g, _h;
21
- main_1.bot.log.info("hello");
22
- main_1.bot.log.info(main_1.bot.info);
23
21
  let embed = new discord_js_1.EmbedBuilder()
24
22
  .setTitle((_b = (_a = main_1.bot.info) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null)
25
23
  .setThumbnail((_d = (_c = main_1.bot.info) === null || _c === void 0 ? void 0 : _c.icon) !== null && _d !== void 0 ? _d : "")
@@ -27,7 +25,6 @@ module.exports = {
27
25
  .addFields({
28
26
  name: "Repository", value: (_h = (_g = main_1.bot.info) === null || _g === void 0 ? void 0 : _g.repo) !== null && _h !== void 0 ? _h : "undefined"
29
27
  });
30
- main_1.bot.log.info(embed.toJSON());
31
28
  yield interaction.reply({ embeds: [embed] });
32
29
  });
33
30
  },
@@ -2,6 +2,7 @@ import { CommandInteraction } from "discord.js";
2
2
  export declare function reply(interaction: CommandInteraction, text: string, args?: Record<string, any>): Promise<void>;
3
3
  export declare class Lang {
4
4
  texts: any;
5
+ static global: Lang;
5
6
  static en: Lang;
6
7
  static embed: Lang;
7
8
  constructor(lang: string);
package/dist/lib/lang.js CHANGED
@@ -57,20 +57,19 @@ function reply(interaction, text, args) {
57
57
  }
58
58
  class Lang {
59
59
  constructor(lang) {
60
+ this.texts = {};
60
61
  const langFileLocation = path_1.default.join(Lang.folder, `${lang}.json`);
61
62
  if (fs_1.default.existsSync(langFileLocation)) {
62
- fs_1.default.readFile(langFileLocation, { encoding: "utf-8" }, (err, data) => {
63
- this.texts = JSON.parse(data);
64
- return;
65
- });
63
+ const data = fs_1.default.readFileSync(langFileLocation, { encoding: "utf-8" });
64
+ this.texts = JSON.parse(data);
66
65
  }
67
- this.texts = null;
68
66
  }
69
67
  static get folder() {
70
68
  return path_1.default.join(main_1.bot.dirname, "lang");
71
69
  }
72
70
  static setup() {
73
71
  return __awaiter(this, void 0, void 0, function* () {
72
+ Lang.global = new Lang("global");
74
73
  Lang.embed = new Lang("embed");
75
74
  Lang.en = new Lang("en");
76
75
  });
@@ -78,6 +77,9 @@ class Lang {
78
77
  get(text, args) {
79
78
  return __awaiter(this, void 0, void 0, function* () {
80
79
  let newText = this.texts[text];
80
+ if (newText === undefined && Lang.global) {
81
+ newText = Lang.global.texts[text];
82
+ }
81
83
  if (typeof newText === "string") {
82
84
  if (args) {
83
85
  for (const [name, value] of Object.entries(args)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-bots/powerbotlibrary",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/main.d.ts",
6
6
  "dependencies": {