From 28285fbe695a958c818ad9f106086bafa67e33a0 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 29 Jun 2022 10:06:38 +0300 Subject: [PATCH] default value --- src/structure/client/wrappers/GuildWrapper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structure/client/wrappers/GuildWrapper.js b/src/structure/client/wrappers/GuildWrapper.js index 448495e..a6be2a5 100644 --- a/src/structure/client/wrappers/GuildWrapper.js +++ b/src/structure/client/wrappers/GuildWrapper.js @@ -128,7 +128,7 @@ class GuildWrapper { async fetchData() { if(this._data) return this._data; const data = await this.client.mongodb.guilds.findOne({ guildId: this.id }); - if (!data) return null; + if (!data) return {}; if (data._version === '3.slash') { const keys = Object.keys(this.defaultConfig); const settings = {}; @@ -148,7 +148,7 @@ class GuildWrapper { async settings(forceFetch = false) { if (this._settings && !forceFetch) return this._settings; - const data = await this.fetchData() || {}; + const data = await this.fetchData(); const { settings } = data; // const settings = await this.client.storageManager.mongodb.guilds.findOne({ guildId: this.id }); // if(this._settings instanceof Promise) this._settings = await this._settings || null; @@ -160,7 +160,7 @@ class GuildWrapper { async updateData(data) { try { await this.client.mongodb.guilds.updateOne({ guildId: this.id }, { _version: configVersion, ...data }); - this._data = { ...this._data, ...data }; + this._data = { ...this._data, ...data, _version: configVersion }; this._storageLog(`Database update: Data (guild:${this.id})`); } catch (err) { this._storageError(err);