mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(CachedManager): return updated data when cache is false (#6685)
This commit is contained in:
@@ -45,8 +45,15 @@ class CachedManager extends DataManager {
|
|||||||
|
|
||||||
_add(data, cache = true, { id, extras = [] } = {}) {
|
_add(data, cache = true, { id, extras = [] } = {}) {
|
||||||
const existing = this.cache.get(id ?? data.id);
|
const existing = this.cache.get(id ?? data.id);
|
||||||
if (cache) existing?._patch(data);
|
if (existing) {
|
||||||
if (existing) return existing;
|
if (cache) {
|
||||||
|
existing._patch(data);
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
const clone = existing._clone();
|
||||||
|
clone._patch(data);
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
const entry = this.holds ? new this.holds(this.client, data, ...extras) : data;
|
const entry = this.holds ? new this.holds(this.client, data, ...extras) : data;
|
||||||
if (cache) this.cache.set(id ?? entry.id, entry);
|
if (cache) this.cache.set(id ?? entry.id, entry);
|
||||||
|
|||||||
Reference in New Issue
Block a user