fix(ThreadChannel): better property handling (#6172)

This commit is contained in:
ckohen
2021-07-27 17:29:06 -07:00
committed by GitHub
parent 30a58dc801
commit 9679b90872
8 changed files with 64 additions and 33 deletions

View File

@@ -19,10 +19,10 @@ class ChannelManager extends CachedManager {
* @name ChannelManager#cache
*/
_add(data, guild, cache = true, allowUnknownGuild = false) {
_add(data, guild, { cache = true, allowUnknownGuild = false, fromInteraction = false } = {}) {
const existing = this.cache.get(data.id);
if (existing) {
if (cache) existing._patch(data);
if (cache) existing._patch(data, fromInteraction);
guild?.channels?._add(existing);
if (ThreadChannelTypes.includes(existing.type)) {
existing.parent?.threads?._add(existing);
@@ -30,7 +30,7 @@ class ChannelManager extends CachedManager {
return existing;
}
const channel = Channel.create(this.client, data, guild, allowUnknownGuild);
const channel = Channel.create(this.client, data, guild, { allowUnknownGuild, fromInteraction });
if (!channel) {
this.client.emit(Events.DEBUG, `Failed to find guild, or unknown type for channel ${data.id} ${data.type}`);
@@ -99,7 +99,7 @@ class ChannelManager extends CachedManager {
}
const data = await this.client.api.channels(id).get();
return this._add(data, null, cache, allowUnknownGuild);
return this._add(data, null, { cache, allowUnknownGuild });
}
}