From e05ebb9b6282994162063c14b31dbb45f33a3e48 Mon Sep 17 00:00:00 2001 From: Navy Date: Sun, 19 Apr 2020 22:54:50 +0300 Subject: [PATCH] fetch settings --- structure/extensions/Guild.js | 144 ++-------------------------------- 1 file changed, 5 insertions(+), 139 deletions(-) diff --git a/structure/extensions/Guild.js b/structure/extensions/Guild.js index 13b0d34..d5e777d 100644 --- a/structure/extensions/Guild.js +++ b/structure/extensions/Guild.js @@ -15,158 +15,24 @@ const Guild = Structures.extend('Guild', (Guild) => { async settings() { - if (!this._settings) this._settings = this.client.transactionHandler._send({ provider: 'mongodb', request: { type: 'findOne', query: { guild: this.id } } }); - if (this._settings instanceof Promise) this._settings = await this._settings; + if (!this._settings) this._settings = this.client.transactionHandler._send({ provider: 'mongodb', request: { collection: 'guild_settings', type: 'findOne', query: { guild: this.id } } }); + if (this._settings instanceof Promise) this._settings = await this._settings || { }; return this._settings; } format(key, parameters = {}) { - const language = "en_us"; //this._settings.language or something idk + + const language = this._settings.locale || "en_us"; //this._settings.language or something idk let value = this.client.localeLoader.languages[language][key]; for(const [param, val] of Object.entries(parameters)) { value = value.replace(new RegExp(`{${escapeRegex(param.toLowerCase())}}`, 'gi'), val); } return value; + } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - async resolveMembers(members, strict = false) { return await this.client.resolver.resolveMembers(members, this, strict);