mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
Fix collectors and make guild sync add previously unknown members
This commit is contained in:
@@ -17,7 +17,9 @@ class GuildMemberRemoveAction extends Action {
|
|||||||
guild.memberCount--;
|
guild.memberCount--;
|
||||||
guild._removeMember(member);
|
guild._removeMember(member);
|
||||||
this.deleted[guild.id + data.user.id] = 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);
|
this.scheduleForDeletion(guild.id, data.user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class GuildSync extends Action {
|
|||||||
const member = guild.members.get(syncMember.user.id);
|
const member = guild.members.get(syncMember.user.id);
|
||||||
if (member) {
|
if (member) {
|
||||||
guild._updateMember(member, syncMember);
|
guild._updateMember(member, syncMember);
|
||||||
|
} else {
|
||||||
|
guild._addMember(syncMember);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ const BeforeReadyWhitelist = [
|
|||||||
Constants.WSEvents.GUILD_CREATE,
|
Constants.WSEvents.GUILD_CREATE,
|
||||||
Constants.WSEvents.GUILD_DELETE,
|
Constants.WSEvents.GUILD_DELETE,
|
||||||
Constants.WSEvents.GUILD_MEMBERS_CHUNK,
|
Constants.WSEvents.GUILD_MEMBERS_CHUNK,
|
||||||
|
Constants.WSEvents.GUILD_MEMBER_ADD,
|
||||||
|
Constants.WSEvents.GUILD_MEMBER_REMOVE,
|
||||||
];
|
];
|
||||||
|
|
||||||
class WebSocketPacketManager {
|
class WebSocketPacketManager {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ const EventEmitter = require('events').EventEmitter;
|
|||||||
* ```js
|
* ```js
|
||||||
* {
|
* {
|
||||||
* time: null, // time in milliseconds. If specified, the collector ends after this amount of time.
|
* 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.
|
* 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) {
|
if (this.channel ? this.channel.id !== message.channel.id : false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (message.author.id === this.channel.client.user.id && !this.options.allowSelf) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.filter(message, this)) {
|
if (this.filter(message, this)) {
|
||||||
this.collected.set(message.id, message);
|
this.collected.set(message.id, message);
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const Discord = require('../');
|
|||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
const fs = require('fs');
|
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');
|
const { email, password, token } = require('./auth.json');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user