From f169c8fe460ef2be6f38d6ee73c55d8b4182e3b7 Mon Sep 17 00:00:00 2001 From: Advaith Date: Wed, 27 Oct 2021 03:07:50 -0700 Subject: [PATCH] fix(ApplicationCommandManager): update guild command cache on c/u/d (#6841) --- src/managers/ApplicationCommandManager.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/managers/ApplicationCommandManager.js b/src/managers/ApplicationCommandManager.js index 3c154a838378..5456dd578f4e 100644 --- a/src/managers/ApplicationCommandManager.js +++ b/src/managers/ApplicationCommandManager.js @@ -117,7 +117,7 @@ class ApplicationCommandManager extends CachedManager { const data = await this.commandPath({ guildId }).post({ data: this.constructor.transformCommand(command), }); - return this._add(data, !guildId, guildId); + return this._add(data, true, guildId); } /** @@ -146,10 +146,7 @@ class ApplicationCommandManager extends CachedManager { const data = await this.commandPath({ guildId }).put({ data: commands.map(c => this.constructor.transformCommand(c)), }); - return data.reduce( - (coll, command) => coll.set(command.id, this._add(command, !guildId, guildId)), - new Collection(), - ); + return data.reduce((coll, command) => coll.set(command.id, this._add(command, true, guildId)), new Collection()); } /** @@ -174,7 +171,7 @@ class ApplicationCommandManager extends CachedManager { const patched = await this.commandPath({ id, guildId }).patch({ data: this.constructor.transformCommand(data), }); - return this._add(patched, !guildId, guildId); + return this._add(patched, true, guildId); } /** @@ -196,7 +193,7 @@ class ApplicationCommandManager extends CachedManager { await this.commandPath({ id, guildId }).delete(); const cached = this.cache.get(id); - if (!guildId) this.cache.delete(id); + this.cache.delete(id); return cached ?? null; }