Fix collectors and make guild sync add previously unknown members

This commit is contained in:
Amish Shah
2016-09-03 21:21:10 +01:00
parent 09dee3d46a
commit 7ff2568cfc
5 changed files with 8 additions and 6 deletions

View File

@@ -17,7 +17,9 @@ class GuildMemberRemoveAction extends Action {
guild.memberCount--;
guild._removeMember(member);
this.deleted[guild.id + data.user.id] = member;
client.emit(Constants.Events.GUILD_MEMBER_REMOVE, guild, member);
if (client.status === Constants.Status.READY) {
client.emit(Constants.Events.GUILD_MEMBER_REMOVE, guild, member);
}
this.scheduleForDeletion(guild.id, data.user.id);
}

View File

@@ -20,6 +20,8 @@ class GuildSync extends Action {
const member = guild.members.get(syncMember.user.id);
if (member) {
guild._updateMember(member, syncMember);
} else {
guild._addMember(syncMember);
}
}
}

View File

@@ -5,6 +5,8 @@ const BeforeReadyWhitelist = [
Constants.WSEvents.GUILD_CREATE,
Constants.WSEvents.GUILD_DELETE,
Constants.WSEvents.GUILD_MEMBERS_CHUNK,
Constants.WSEvents.GUILD_MEMBER_ADD,
Constants.WSEvents.GUILD_MEMBER_REMOVE,
];
class WebSocketPacketManager {

View File

@@ -21,7 +21,6 @@ const EventEmitter = require('events').EventEmitter;
* ```js
* {
* time: null, // time in milliseconds. If specified, the collector ends after this amount of time.
* allowSelf: false, // whether or not the filter should take messages from the logged in client.
* max: null, // the maximum amount of messages to handle before ending.
* }
* ```
@@ -77,9 +76,6 @@ class MessageCollector extends EventEmitter {
if (this.channel ? this.channel.id !== message.channel.id : false) {
return false;
}
if (message.author.id === this.channel.client.user.id && !this.options.allowSelf) {
return false;
}
if (this.filter(message, this)) {
this.collected.set(message.id, message);
/**

View File

@@ -4,7 +4,7 @@ const Discord = require('../');
const request = require('superagent');
const fs = require('fs');
const client = new Discord.Client({ fetch_all_members: true });
const client = new Discord.Client({ fetch_all_members: false });
const { email, password, token } = require('./auth.json');