Skip to content

Commit

Permalink
backport: GUILD_INTEGRATIONS_UPDATE event (#2794)
Browse files Browse the repository at this point in the history
* backport: Client#on{guildIntegrationsUpdate,webhookUpdate}

misc: Update Constants.WSEvents and WSEventType

backport: Add guildIntegrationsUpdate event handler

* docs: Updated typings
  • Loading branch information
kyranet authored and Lewdcario committed Aug 28, 2018
1 parent 1fc84a9 commit 3345c77
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client/websocket/packets/WebSocketPacketManager.js
Expand Up @@ -31,6 +31,7 @@ class WebSocketPacketManager {
this.register(Constants.WSEvents.GUILD_ROLE_UPDATE, require('./handlers/GuildRoleUpdate'));
this.register(Constants.WSEvents.GUILD_EMOJIS_UPDATE, require('./handlers/GuildEmojisUpdate'));
this.register(Constants.WSEvents.GUILD_MEMBERS_CHUNK, require('./handlers/GuildMembersChunk'));
this.register(Constants.WSEvents.GUILD_INTEGRATIONS_UPDATE, require('./handlers/GuildIntegrationsUpdate'));
this.register(Constants.WSEvents.CHANNEL_CREATE, require('./handlers/ChannelCreate'));
this.register(Constants.WSEvents.CHANNEL_DELETE, require('./handlers/ChannelDelete'));
this.register(Constants.WSEvents.CHANNEL_UPDATE, require('./handlers/ChannelUpdate'));
Expand Down
19 changes: 19 additions & 0 deletions src/client/websocket/packets/handlers/GuildIntegrationsUpdate.js
@@ -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
*/
3 changes: 3 additions & 0 deletions src/util/Constants.js
Expand Up @@ -319,6 +319,7 @@ exports.Events = {
GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable',
GUILD_MEMBER_SPEAKING: 'guildMemberSpeaking',
GUILD_MEMBERS_CHUNK: 'guildMembersChunk',
GUILD_INTEGRATIONS_UPDATE: 'guildIntegrationsUpdate',
GUILD_ROLE_CREATE: 'roleCreate',
GUILD_ROLE_DELETE: 'roleDelete',
GUILD_ROLE_UPDATE: 'roleUpdate',
Expand Down Expand Up @@ -390,6 +391,7 @@ exports.ActivityFlags = {
* * GUILD_MEMBER_REMOVE
* * GUILD_MEMBER_UPDATE
* * GUILD_MEMBERS_CHUNK
* * GUILD_INTEGRATIONS_UPDATE
* * GUILD_ROLE_CREATE
* * GUILD_ROLE_DELETE
* * GUILD_ROLE_UPDATE
Expand Down Expand Up @@ -429,6 +431,7 @@ exports.WSEvents = {
GUILD_MEMBER_REMOVE: 'GUILD_MEMBER_REMOVE',
GUILD_MEMBER_UPDATE: 'GUILD_MEMBER_UPDATE',
GUILD_MEMBERS_CHUNK: 'GUILD_MEMBERS_CHUNK',
GUILD_INTEGRATIONS_UPDATE: 'GUILD_INTEGRATIONS_UPDATE',
GUILD_ROLE_CREATE: 'GUILD_ROLE_CREATE',
GUILD_ROLE_DELETE: 'GUILD_ROLE_DELETE',
GUILD_ROLE_UPDATE: 'GUILD_ROLE_UPDATE',
Expand Down
3 changes: 3 additions & 0 deletions typings/index.d.ts
Expand Up @@ -130,6 +130,7 @@ declare module 'discord.js' {
public on(event: 'guildMemberUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
public on(event: 'guildUnavailable', listener: (guild: Guild) => void): this;
public on(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this;
public on(event: 'guildIntegrationsUpdate', listener: (guild: Guild) => void): this;
public on(event: 'message', listener: (message: Message) => void): this;
public on(event: 'messageDelete', listener: (message: Message) => void): this;
public on(event: 'messageDeleteBulk', listener: (messages: Collection<Snowflake, Message>) => void): this;
Expand Down Expand Up @@ -178,6 +179,7 @@ declare module 'discord.js' {
public once(event: 'guildMemberUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
public once(event: 'guildUnavailable', listener: (guild: Guild) => void): this;
public once(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this;
public once(event: 'guildIntegrationsUpdate', listener: (guild: Guild) => void): this;
public once(event: 'message', listener: (message: Message) => void): this;
public once(event: 'messageDelete', listener: (message: Message) => void): this;
public once(event: 'messageDeleteBulk', listener: (messages: Collection<Snowflake, Message>) => void): this;
Expand Down Expand Up @@ -2106,6 +2108,7 @@ declare module 'discord.js' {
| 'GUILD_MEMBER_REMOVE'
| 'GUILD_MEMBER_UPDATE'
| 'GUILD_MEMBERS_CHUNK'
| 'GUILD_INTEGRATIONS_UPDATE'
| 'GUILD_ROLE_CREATE'
| 'GUILD_ROLE_DELETE'
| 'GUILD_ROLE_UPDATE'
Expand Down

0 comments on commit 3345c77

Please sign in to comment.