From 4d7fc036a1c8e0b80c67242ab6f1eebf69a3fad6 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Sat, 27 Apr 2019 11:46:48 +0100 Subject: [PATCH] fix: channels being removed from guild.channels --- src/stores/ChannelStore.js | 7 +++++-- src/stores/GuildChannelStore.js | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/stores/ChannelStore.js b/src/stores/ChannelStore.js index aad7927aa..e745eea33 100644 --- a/src/stores/ChannelStore.js +++ b/src/stores/ChannelStore.js @@ -54,8 +54,11 @@ class ChannelStore extends DataStore { add(data, guild, cache = true) { const existing = this.get(data.id); - if (existing && existing.partial && cache) existing._patch(data); - if (existing) return existing; + if (existing && existing._patch && cache) existing._patch(data); + if (existing) { + guild.channels.add(existing); + return existing; + } const channel = Channel.create(this.client, data, guild); diff --git a/src/stores/GuildChannelStore.js b/src/stores/GuildChannelStore.js index 7d95cfe2c..fc150f17b 100644 --- a/src/stores/GuildChannelStore.js +++ b/src/stores/GuildChannelStore.js @@ -1,6 +1,5 @@ 'use strict'; -const Channel = require('../structures/Channel'); const { ChannelTypes } = require('../util/Constants'); const DataStore = require('./DataStore'); const GuildChannel = require('../structures/GuildChannel'); @@ -16,11 +15,11 @@ class GuildChannelStore extends DataStore { this.guild = guild; } - add(data) { - const existing = this.get(data.id); + add(channel) { + const existing = this.get(channel.id); if (existing) return existing; - - return Channel.create(this.client, data, this.guild); + this.set(channel.id, channel); + return channel; } /**