-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix guild.members.fetch() New event: guildMemberListUpdate (same as guildMemberChunk)
- Loading branch information
1 parent
9672b32
commit 89d8b08
Showing
7 changed files
with
194 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const { Collection } = require('@discordjs/collection'); | ||
const { Events } = require('../../../util/Constants'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
// console.log(data); | ||
// console.log(data.ops[0]) | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
if (!guild) return; | ||
const members = new Collection(); | ||
for (const object of data.ops) { | ||
if (object.op == 'SYNC') { | ||
for (const member_ of object.items) { | ||
const member = member_.member; | ||
if (!member) continue; | ||
members.set(member.user.id, guild.members._add(member)); | ||
if (member.presence) | ||
guild.presences._add(Object.assign(member.presence, { guild })); | ||
} | ||
} else if (object.op == 'INVALIDATE') { | ||
console.warn(`Invalidate [${object.range[0]}, ${object.range[1]}]`); | ||
} else if (object.op == 'UPDATE' || object.op == 'INSERT') { | ||
const member = object.item.member; | ||
if (!member) continue; | ||
members.set(member.user.id, guild.members._add(member)); | ||
if (member.presence) | ||
guild.presences._add(Object.assign(member.presence, { guild })); | ||
} else if (object.op == 'DELETE') { | ||
// nothing; | ||
} | ||
} | ||
client.emit(Events.GUILD_MEMBER_LIST_UPDATE, members, guild, data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,68 @@ | ||
'use strict'; | ||
|
||
const handlers = Object.fromEntries([ | ||
['READY', require('./READY')], | ||
['RESUMED', require('./RESUMED')], | ||
['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')], | ||
['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')], | ||
['APPLICATION_COMMAND_UPDATE', require('./APPLICATION_COMMAND_UPDATE')], | ||
['GUILD_CREATE', require('./GUILD_CREATE')], | ||
['GUILD_DELETE', require('./GUILD_DELETE')], | ||
['GUILD_UPDATE', require('./GUILD_UPDATE')], | ||
['INVITE_CREATE', require('./INVITE_CREATE')], | ||
['INVITE_DELETE', require('./INVITE_DELETE')], | ||
['GUILD_MEMBER_ADD', require('./GUILD_MEMBER_ADD')], | ||
['GUILD_MEMBER_REMOVE', require('./GUILD_MEMBER_REMOVE')], | ||
['GUILD_MEMBER_UPDATE', require('./GUILD_MEMBER_UPDATE')], | ||
['GUILD_MEMBERS_CHUNK', require('./GUILD_MEMBERS_CHUNK')], | ||
['READY', require('./READY')], | ||
['RESUMED', require('./RESUMED')], | ||
['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')], | ||
['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')], | ||
['APPLICATION_COMMAND_UPDATE', require('./APPLICATION_COMMAND_UPDATE')], | ||
['GUILD_CREATE', require('./GUILD_CREATE')], | ||
['GUILD_DELETE', require('./GUILD_DELETE')], | ||
['GUILD_UPDATE', require('./GUILD_UPDATE')], | ||
['INVITE_CREATE', require('./INVITE_CREATE')], | ||
['INVITE_DELETE', require('./INVITE_DELETE')], | ||
['GUILD_MEMBER_ADD', require('./GUILD_MEMBER_ADD')], | ||
['GUILD_MEMBER_REMOVE', require('./GUILD_MEMBER_REMOVE')], | ||
['GUILD_MEMBER_UPDATE', require('./GUILD_MEMBER_UPDATE')], | ||
['GUILD_MEMBERS_CHUNK', require('./GUILD_MEMBERS_CHUNK')], | ||
['GUILD_MEMBER_LIST_UPDATE', require('./GUILD_MEMBER_LIST_UPDATE.js')], | ||
['GUILD_INTEGRATIONS_UPDATE', require('./GUILD_INTEGRATIONS_UPDATE')], | ||
['GUILD_ROLE_CREATE', require('./GUILD_ROLE_CREATE')], | ||
['GUILD_ROLE_DELETE', require('./GUILD_ROLE_DELETE')], | ||
['GUILD_ROLE_UPDATE', require('./GUILD_ROLE_UPDATE')], | ||
['GUILD_BAN_ADD', require('./GUILD_BAN_ADD')], | ||
['GUILD_BAN_REMOVE', require('./GUILD_BAN_REMOVE')], | ||
['GUILD_EMOJIS_UPDATE', require('./GUILD_EMOJIS_UPDATE')], | ||
['CHANNEL_CREATE', require('./CHANNEL_CREATE')], | ||
['CHANNEL_DELETE', require('./CHANNEL_DELETE')], | ||
['CHANNEL_UPDATE', require('./CHANNEL_UPDATE')], | ||
['CHANNEL_PINS_UPDATE', require('./CHANNEL_PINS_UPDATE')], | ||
['MESSAGE_CREATE', require('./MESSAGE_CREATE')], | ||
['MESSAGE_DELETE', require('./MESSAGE_DELETE')], | ||
['MESSAGE_UPDATE', require('./MESSAGE_UPDATE')], | ||
['MESSAGE_DELETE_BULK', require('./MESSAGE_DELETE_BULK')], | ||
['MESSAGE_REACTION_ADD', require('./MESSAGE_REACTION_ADD')], | ||
['MESSAGE_REACTION_REMOVE', require('./MESSAGE_REACTION_REMOVE')], | ||
['MESSAGE_REACTION_REMOVE_ALL', require('./MESSAGE_REACTION_REMOVE_ALL')], | ||
['MESSAGE_REACTION_REMOVE_EMOJI', require('./MESSAGE_REACTION_REMOVE_EMOJI')], | ||
['THREAD_CREATE', require('./THREAD_CREATE')], | ||
['THREAD_UPDATE', require('./THREAD_UPDATE')], | ||
['THREAD_DELETE', require('./THREAD_DELETE')], | ||
['THREAD_LIST_SYNC', require('./THREAD_LIST_SYNC')], | ||
['THREAD_MEMBER_UPDATE', require('./THREAD_MEMBER_UPDATE')], | ||
['THREAD_MEMBERS_UPDATE', require('./THREAD_MEMBERS_UPDATE')], | ||
['USER_UPDATE', require('./USER_UPDATE')], | ||
['PRESENCE_UPDATE', require('./PRESENCE_UPDATE')], | ||
['TYPING_START', require('./TYPING_START')], | ||
['VOICE_STATE_UPDATE', require('./VOICE_STATE_UPDATE')], | ||
['VOICE_SERVER_UPDATE', require('./VOICE_SERVER_UPDATE')], | ||
['WEBHOOKS_UPDATE', require('./WEBHOOKS_UPDATE')], | ||
['INTERACTION_CREATE', require('./INTERACTION_CREATE')], | ||
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')], | ||
['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')], | ||
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')], | ||
['GUILD_STICKERS_UPDATE', require('./GUILD_STICKERS_UPDATE')], | ||
['GUILD_SCHEDULED_EVENT_CREATE', require('./GUILD_SCHEDULED_EVENT_CREATE')], | ||
['GUILD_SCHEDULED_EVENT_UPDATE', require('./GUILD_SCHEDULED_EVENT_UPDATE')], | ||
['GUILD_SCHEDULED_EVENT_DELETE', require('./GUILD_SCHEDULED_EVENT_DELETE')], | ||
['GUILD_SCHEDULED_EVENT_USER_ADD', require('./GUILD_SCHEDULED_EVENT_USER_ADD')], | ||
['GUILD_SCHEDULED_EVENT_USER_REMOVE', require('./GUILD_SCHEDULED_EVENT_USER_REMOVE')], | ||
['GUILD_ROLE_CREATE', require('./GUILD_ROLE_CREATE')], | ||
['GUILD_ROLE_DELETE', require('./GUILD_ROLE_DELETE')], | ||
['GUILD_ROLE_UPDATE', require('./GUILD_ROLE_UPDATE')], | ||
['GUILD_BAN_ADD', require('./GUILD_BAN_ADD')], | ||
['GUILD_BAN_REMOVE', require('./GUILD_BAN_REMOVE')], | ||
['GUILD_EMOJIS_UPDATE', require('./GUILD_EMOJIS_UPDATE')], | ||
['CHANNEL_CREATE', require('./CHANNEL_CREATE')], | ||
['CHANNEL_DELETE', require('./CHANNEL_DELETE')], | ||
['CHANNEL_UPDATE', require('./CHANNEL_UPDATE')], | ||
['CHANNEL_PINS_UPDATE', require('./CHANNEL_PINS_UPDATE')], | ||
['MESSAGE_CREATE', require('./MESSAGE_CREATE')], | ||
['MESSAGE_DELETE', require('./MESSAGE_DELETE')], | ||
['MESSAGE_UPDATE', require('./MESSAGE_UPDATE')], | ||
['MESSAGE_DELETE_BULK', require('./MESSAGE_DELETE_BULK')], | ||
['MESSAGE_REACTION_ADD', require('./MESSAGE_REACTION_ADD')], | ||
['MESSAGE_REACTION_REMOVE', require('./MESSAGE_REACTION_REMOVE')], | ||
['MESSAGE_REACTION_REMOVE_ALL', require('./MESSAGE_REACTION_REMOVE_ALL')], | ||
['MESSAGE_REACTION_REMOVE_EMOJI', require('./MESSAGE_REACTION_REMOVE_EMOJI')], | ||
['THREAD_CREATE', require('./THREAD_CREATE')], | ||
['THREAD_UPDATE', require('./THREAD_UPDATE')], | ||
['THREAD_DELETE', require('./THREAD_DELETE')], | ||
['THREAD_LIST_SYNC', require('./THREAD_LIST_SYNC')], | ||
['THREAD_MEMBER_UPDATE', require('./THREAD_MEMBER_UPDATE')], | ||
['THREAD_MEMBERS_UPDATE', require('./THREAD_MEMBERS_UPDATE')], | ||
['USER_UPDATE', require('./USER_UPDATE')], | ||
['PRESENCE_UPDATE', require('./PRESENCE_UPDATE')], | ||
['TYPING_START', require('./TYPING_START')], | ||
['VOICE_STATE_UPDATE', require('./VOICE_STATE_UPDATE')], | ||
['VOICE_SERVER_UPDATE', require('./VOICE_SERVER_UPDATE')], | ||
['WEBHOOKS_UPDATE', require('./WEBHOOKS_UPDATE')], | ||
['INTERACTION_CREATE', require('./INTERACTION_CREATE')], | ||
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')], | ||
['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')], | ||
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')], | ||
['GUILD_STICKERS_UPDATE', require('./GUILD_STICKERS_UPDATE')], | ||
['GUILD_SCHEDULED_EVENT_CREATE', require('./GUILD_SCHEDULED_EVENT_CREATE')], | ||
['GUILD_SCHEDULED_EVENT_UPDATE', require('./GUILD_SCHEDULED_EVENT_UPDATE')], | ||
['GUILD_SCHEDULED_EVENT_DELETE', require('./GUILD_SCHEDULED_EVENT_DELETE')], | ||
[ | ||
'GUILD_SCHEDULED_EVENT_USER_ADD', | ||
require('./GUILD_SCHEDULED_EVENT_USER_ADD'), | ||
], | ||
[ | ||
'GUILD_SCHEDULED_EVENT_USER_REMOVE', | ||
require('./GUILD_SCHEDULED_EVENT_USER_REMOVE'), | ||
], | ||
]); | ||
|
||
module.exports = handlers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters