forked from Galactic/galactic-bot
ensure settings always contain latest properties
This commit is contained in:
parent
746e395382
commit
e3fbbd9a17
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user