discord.js-selfbot-v13/src/client/actions/ThreadMembersUpdate.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-03-19 10:37:45 +00:00
'use strict';
const Action = require('./Action');
const { Events } = require('../../util/Constants');
2022-03-19 10:37:45 +00:00
class ThreadMembersUpdateAction extends Action {
handle(data) {
const client = this.client;
const thread = client.channels.cache.get(data.id);
if (thread) {
const old = thread.members.cache.clone();
thread.memberCount = data.member_count;
data.added_members?.forEach(rawMember => {
thread.members._add(rawMember);
});
data.removed_member_ids?.forEach(memberId => {
thread.members.cache.delete(memberId);
});
/**
* Emitted whenever members are added or removed from a thread. Requires `GUILD_MEMBERS` privileged intent
* @event Client#threadMembersUpdate
* @param {Collection<Snowflake, ThreadMember>} oldMembers The members before the update
* @param {Collection<Snowflake, ThreadMember>} newMembers The members after the update
*/
client.emit(Events.THREAD_MEMBERS_UPDATE, old, thread.members.cache);
2022-03-19 10:37:45 +00:00
}
return {};
}
}
module.exports = ThreadMembersUpdateAction;