feat: Guild Integrations (#2760)

* feat: Guild Integrations

* feat: Guild#createIntegration

* feat: Add ws event GUILD_INTEGRATIONS_UPDATE

* docs: Add `GUILD_INTEGRATIONS_UPDATE` to WSEventType

* misc: Fixed requested change

* docs: Updated typings

* typings: Sort members by name
This commit is contained in:
Kyra
2018-08-24 16:03:29 +02:00
committed by Crawl
parent 13f46b924b
commit c4df02782e
7 changed files with 253 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ class WebSocketPacketManager {
this.register(WSEvents.GUILD_ROLE_UPDATE, require('./handlers/GuildRoleUpdate'));
this.register(WSEvents.GUILD_EMOJIS_UPDATE, require('./handlers/GuildEmojisUpdate'));
this.register(WSEvents.GUILD_MEMBERS_CHUNK, require('./handlers/GuildMembersChunk'));
this.register(WSEvents.GUILD_INTEGRATIONS_UPDATE, require('./handlers/GuildIntegrationsUpdate'));
this.register(WSEvents.CHANNEL_CREATE, require('./handlers/ChannelCreate'));
this.register(WSEvents.CHANNEL_DELETE, require('./handlers/ChannelDelete'));
this.register(WSEvents.CHANNEL_UPDATE, require('./handlers/ChannelUpdate'));

View File

@@ -0,0 +1,19 @@
const AbstractHandler = require('./AbstractHandler');
const { Events } = require('../../../../util/Constants');
class GuildIntegrationsHandler extends AbstractHandler {
handle(packet) {
const client = this.packetManager.client;
const data = packet.d;
const guild = client.guilds.get(data.guild_id);
if (guild) client.emit(Events.GUILD_INTEGRATIONS_UPDATE, guild);
}
}
module.exports = GuildIntegrationsHandler;
/**
* Emitted whenever a guild integration is updated
* @event Client#guildIntegrationsUpdate
* @param {Guild} guild The guild whose integrations were updated
*/