Added GuildMembersChunk handler; untested

This commit is contained in:
hydrabolt
2016-04-18 16:54:14 +01:00
parent ce2cf382b3
commit c36cc3b551
4 changed files with 35 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ class WebSocketPacketManager {
this.register(Constants.WSEvents.GUILD_ROLE_CREATE, 'GuildRoleCreate');
this.register(Constants.WSEvents.GUILD_ROLE_DELETE, 'GuildRoleDelete');
this.register(Constants.WSEvents.GUILD_ROLE_UPDATE, 'GuildRoleUpdate');
this.register(Constants.WSEvents.GUILD_MEMBERS_CHUNK, 'GuildMembersChunk');
this.register(Constants.WSEvents.CHANNEL_CREATE, 'ChannelCreate');
this.register(Constants.WSEvents.CHANNEL_DELETE, 'ChannelDelete');
this.register(Constants.WSEvents.CHANNEL_UPDATE, 'ChannelUpdate');

View File

@@ -0,0 +1,33 @@
'use strict';
// ##untested##
const AbstractHandler = require('./AbstractHandler');
const Structure = name => require(`../../../../structures/${name}`);
const Constants = require('../../../../util/Constants');
const CloneObject = require('../../../../util/CloneObject');
class GuildMembersChunkHandler extends AbstractHandler {
constructor(packetManager) {
super(packetManager);
}
handle(packet) {
let data = packet.d;
let client = this.packetManager.client;
let guild = client.store.get('guilds', data.guild_id);
let members = [];
if (guild) {
for (let member of guild.members) {
members.push(guild._addMember(member, true));
}
}
client.emit(Constants.Events.GUILD_MEMBERS_CHUNK, guild, members);
}
};
module.exports = GuildMembersChunkHandler;

View File

@@ -5,8 +5,6 @@ const Structure = name => require(`../../../../structures/${name}`);
const Constants = require('../../../../util/Constants');
const CloneObject = require('../../../../util/CloneObject');
const Role = Structure('User');
class TypingData {
constructor(since, lastTimestamp, _timeout) {
this.since = since;

View File

@@ -97,6 +97,7 @@ const Events = exports.Events = {
TYPING_START: 'typingStart',
TYPING_STOP: 'typingStop',
WARN: 'warn',
GUILD_MEMBERS_CHUNK: 'guildMembersChunk',
};
const WSEvents = exports.WSEvents = {