From d42ac98339ded93a366deb15d9e7f10150c419e9 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Mon, 24 Oct 2016 15:47:31 +0100 Subject: [PATCH 1/2] Fix #775 (permission overwrites not taking into account previous values) --- src/structures/GuildChannel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index de1cd2726..7d220cf6c 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -144,8 +144,8 @@ class GuildChannel extends Channel { const prevOverwrite = this.permissionOverwrites.get(userOrRole.id); if (prevOverwrite) { - payload.allow = prevOverwrite.allow; - payload.deny = prevOverwrite.deny; + payload.allow = prevOverwrite.allowData; + payload.deny = prevOverwrite.denyData; } for (const perm in options) { From 6093dac5544781e29f259f281fbb44629b5ff5a0 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Mon, 24 Oct 2016 15:57:07 +0100 Subject: [PATCH 2/2] Fix #776 (guildMemberAdd firing for existing members) --- src/structures/Guild.js | 3 ++- test/random.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index d8dae531f..7c7fcd4a9 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -679,6 +679,7 @@ class Guild { } _addMember(guildUser, emitEvent = true) { + const existing = this.members.has(guildUser.user.id); if (!(guildUser.user instanceof User)) guildUser.user = this.client.dataManager.newUser(guildUser.user); guildUser.joined_at = guildUser.joined_at || 0; @@ -702,7 +703,7 @@ class Guild { * @param {Guild} guild The guild that the user has joined * @param {GuildMember} member The member that has joined */ - if (this.client.ws.status === Constants.Status.READY && emitEvent) { + if (this.client.ws.status === Constants.Status.READY && emitEvent && !existing) { this.client.emit(Constants.Events.GUILD_MEMBER_ADD, this, member); } diff --git a/test/random.js b/test/random.js index 9ad71b3a4..27db94d86 100644 --- a/test/random.js +++ b/test/random.js @@ -20,6 +20,8 @@ client.on('userUpdate', (o, n) => { console.log(o.username, n.username); }); +client.on('guildMemberAdd', (g, m) => console.log(`${m.user.username} joined ${g.name}`)); + client.on('channelCreate', channel => { console.log(`made ${channel.name}`); });