From f6e3f6c38d4ac5efc8908317d3a6f514f7c1f3a4 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Thu, 1 Sep 2022 19:58:00 +0300 Subject: [PATCH] bugfix --- src/structure/DiscordClient.js | 4 ++-- src/structure/components/observers/UtilityHook.js | 2 +- src/utilities/SettingsMigrator.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index f38970c..2a24852 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -191,7 +191,7 @@ class DiscordClient extends Client { } defaultConfig(type) { - if(this._defaultConfig[type]) return this._defaultConfig[type]; + if (this._defaultConfig[type]) return JSON.parse(JSON.stringify(this._defaultConfig[type])); const settings = this.registry.components.filter((c) => c._type === 'setting' && c.resolve === type); let def = type === 'GUILD' ? DefaultGuild : DefaultUser; for(const setting of settings.values()) { @@ -203,7 +203,7 @@ class DiscordClient extends Client { } } this._defaultConfig[type] = def; - return def; + return JSON.parse(JSON.stringify(def)); } async _setActivity() { diff --git a/src/structure/components/observers/UtilityHook.js b/src/structure/components/observers/UtilityHook.js index abe53cd..3d82afd 100644 --- a/src/structure/components/observers/UtilityHook.js +++ b/src/structure/components/observers/UtilityHook.js @@ -122,7 +122,7 @@ class UtilityHook extends Observer { const me = await guild.resolveMember(this.client.user); if (!me.permissions.has('ManageRoles')) return; - const _roles = await guild.resolveRoles(setting.roles); + const _roles = await guild.resolveRoles(setting.roles || []); if (_roles.some((r) => r.position >= me.roles.highest.position)) return; const roles = _roles.map((r) => r.id); // Sometimes the member isn't available on the API for some reason, diff --git a/src/utilities/SettingsMigrator.js b/src/utilities/SettingsMigrator.js index c1c61b9..4722404 100644 --- a/src/utilities/SettingsMigrator.js +++ b/src/utilities/SettingsMigrator.js @@ -215,7 +215,7 @@ class SettingsMigrator { const { moderation, modlogs, muterole, mutetype, automod, wordFilter, ignore, invitefilter, chatlogs, activity, selfrole, killitwithfire, memberlogs, staffRole, staffRule, modpoints, userlogs, grantable, privatelog, linkfilter, autorole, welcomer, prefix, protection } = result; - const settings = this.client.defaultConfig('GUILD'); + const settings = JSON.parse(JSON.stringify(this.client.defaultConfig('GUILD'))); if (staffRole || staffRole) { settings.staff = {