From bf0a68dbac7b0fa551041089898034e631360005 Mon Sep 17 00:00:00 2001 From: Yukine Date: Sat, 20 Jan 2018 08:00:44 +0100 Subject: [PATCH 1/3] Mark DataStores as public to directly display them in the docs. (#2268) * make EmojiStore not Private anymore. because why have something private if there is priority functionality on that class? also that causes that the docs wont show it directly * make GuildChannelStore not private anymore because why have something private if there is priority functionality on that class? also that causes that the docs wont show it directly * make RoleStore not private anymore because why have something private if there is priority functionality on that class? also that causes that the docs wont show it directly * make ReactionStore not private anymore because why have something private if there is priority functionality on that class? also that causes that the docs wont show it directly * make all non private to stay consistent * fix merge conflicts because of other PRs. --- src/stores/ChannelStore.js | 1 - src/stores/ClientPresenceStore.js | 1 - src/stores/GuildChannelStore.js | 1 - src/stores/GuildEmojiStore.js | 1 - src/stores/GuildStore.js | 1 - src/stores/PresenceStore.js | 1 - src/stores/ReactionStore.js | 1 - src/stores/RoleStore.js | 1 - 8 files changed, 8 deletions(-) diff --git a/src/stores/ChannelStore.js b/src/stores/ChannelStore.js index 53a81358c..6e2e4081a 100644 --- a/src/stores/ChannelStore.js +++ b/src/stores/ChannelStore.js @@ -7,7 +7,6 @@ const lruable = ['group', 'dm']; /** * Stores channels. - * @private * @extends {DataStore} */ class ChannelStore extends DataStore { diff --git a/src/stores/ClientPresenceStore.js b/src/stores/ClientPresenceStore.js index 12213059c..a6eedb7ce 100644 --- a/src/stores/ClientPresenceStore.js +++ b/src/stores/ClientPresenceStore.js @@ -7,7 +7,6 @@ const { TypeError } = require('../errors'); /** * Stores the client presence and other presences. * @extends {PresenceStore} - * @private */ class ClientPresenceStore extends PresenceStore { constructor(...args) { diff --git a/src/stores/GuildChannelStore.js b/src/stores/GuildChannelStore.js index f37c58853..c4d0c6fea 100644 --- a/src/stores/GuildChannelStore.js +++ b/src/stores/GuildChannelStore.js @@ -7,7 +7,6 @@ const Permissions = require('../util/Permissions'); /** * Stores guild channels. - * @private * @extends {DataStore} */ class GuildChannelStore extends DataStore { diff --git a/src/stores/GuildEmojiStore.js b/src/stores/GuildEmojiStore.js index 0fc4cc60b..bc5c57280 100644 --- a/src/stores/GuildEmojiStore.js +++ b/src/stores/GuildEmojiStore.js @@ -6,7 +6,6 @@ const DataResolver = require('../util/DataResolver'); /** * Stores guild emojis. - * @private * @extends {DataStore} */ class GuildEmojiStore extends DataStore { diff --git a/src/stores/GuildStore.js b/src/stores/GuildStore.js index 7b7810aee..35701087f 100644 --- a/src/stores/GuildStore.js +++ b/src/stores/GuildStore.js @@ -5,7 +5,6 @@ const Guild = require('../structures/Guild'); /** * Stores guilds. - * @private * @extends {DataStore} */ class GuildStore extends DataStore { diff --git a/src/stores/PresenceStore.js b/src/stores/PresenceStore.js index 1b927934e..79f0c525c 100644 --- a/src/stores/PresenceStore.js +++ b/src/stores/PresenceStore.js @@ -3,7 +3,6 @@ const { Presence } = require('../structures/Presence'); /** * Stores presences. - * @private * @extends {DataStore} */ class PresenceStore extends DataStore { diff --git a/src/stores/ReactionStore.js b/src/stores/ReactionStore.js index 4a689a447..38c467b79 100644 --- a/src/stores/ReactionStore.js +++ b/src/stores/ReactionStore.js @@ -3,7 +3,6 @@ const MessageReaction = require('../structures/MessageReaction'); /** * Stores reactions. - * @private * @extends {DataStore} */ class ReactionStore extends DataStore { diff --git a/src/stores/RoleStore.js b/src/stores/RoleStore.js index 2b5f9ee10..55eeaa944 100644 --- a/src/stores/RoleStore.js +++ b/src/stores/RoleStore.js @@ -5,7 +5,6 @@ const Permissions = require('../util/Permissions'); /** * Stores roles. - * @private * @extends {DataStore} */ class RoleStore extends DataStore { From a22b856494a8c599c9d1acea4edb8a210c1a12d1 Mon Sep 17 00:00:00 2001 From: Pascal Date: Sat, 20 Jan 2018 09:05:07 +0100 Subject: [PATCH 2/3] fix(WebSocketConnection): make errors in event handlers throw again The error from something like client.on('ready', () => undefined.f); would just be emitted as debug event instead of being thrown. Simply moving the emitting part out of the try catch again solves this. --- src/client/websocket/WebSocketConnection.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/websocket/WebSocketConnection.js b/src/client/websocket/WebSocketConnection.js index 4e3835ef0..5e07b1a69 100644 --- a/src/client/websocket/WebSocketConnection.js +++ b/src/client/websocket/WebSocketConnection.js @@ -269,13 +269,15 @@ class WebSocketConnection extends EventEmitter { this.inflate.push(data, flush && zlib.Z_SYNC_FLUSH); if (!flush) return; + let packet; try { - const packet = WebSocket.unpack(this.inflate.result); - this.onPacket(packet); - if (this.client.listenerCount('raw')) this.client.emit('raw', packet); + packet = WebSocket.unpack(this.inflate.result); } catch (err) { this.client.emit('debug', err); + return; } + this.onPacket(packet); + if (this.client.listenerCount('raw')) this.client.emit('raw', packet); } /** From fbd25f867742bac5511e47bbf69274bdc82ccb23 Mon Sep 17 00:00:00 2001 From: Pascal Date: Sat, 20 Jan 2018 12:44:27 +0100 Subject: [PATCH 3/3] fix(GuildMember): make edit method only modify a copy of the voice state This is to fix stale members in voice channels. --- src/structures/GuildMember.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index 08561c757..038527929 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -357,7 +357,8 @@ class GuildMember extends Base { const clone = this._clone(); data.user = this.user; clone._patch(data); - clone._frozenVoiceState = this.voiceState; + clone._frozenVoiceState = {}; + Object.assign(clone._frozenVoiceState, this.voiceState); if (typeof data.mute !== 'undefined') clone._frozenVoiceState.mute = data.mute; if (typeof data.deaf !== 'undefined') clone._frozenVoiceState.mute = data.deaf; if (typeof data.channel_id !== 'undefined') clone._frozenVoiceState.channel_id = data.channel_id;