From e3fbbd9a17df99a2980add9c81b5d531347c3030 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 30 Jul 2022 17:59:35 +0300 Subject: [PATCH] ensure settings always contain latest properties --- src/structure/client/wrappers/GuildWrapper.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/structure/client/wrappers/GuildWrapper.js b/src/structure/client/wrappers/GuildWrapper.js index f639570..9fa316f 100644 --- a/src/structure/client/wrappers/GuildWrapper.js +++ b/src/structure/client/wrappers/GuildWrapper.js @@ -153,10 +153,19 @@ class GuildWrapper { const data = await this.fetchData(); const { settings } = data; + const { defaultConfig } = this; - if(!settings) this._settings = { guildId: this.id, ...this.defaultConfig }; - else this._settings = { ...this.defaultConfig, ...settings }; - + if (settings) { + // Ensure new settings properties are propagated to existing configs + const keys = Object.keys(settings); + for (const key of keys) { + if (!(key in defaultConfig)) continue; + defaultConfig[key] = { ...defaultConfig[key], ...settings[key] }; + } + + } + + this._settings = defaultConfig; return this._settings; }