Skip to content

Commit

Permalink
backport: WEBHOOKS_UPDATE event (#2779)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet authored and Lewdcario committed Aug 26, 2018
1 parent 93bf430 commit 4530981
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client/websocket/packets/WebSocketPacketManager.js
Expand Up @@ -53,6 +53,7 @@ class WebSocketPacketManager {
this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, require('./handlers/MessageReactionAdd'));
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemove'));
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, require('./handlers/MessageReactionRemoveAll'));
this.register(Constants.WSEvents.WEBHOOKS_UPDATE, require('./handlers/WebhooksUpdate'));
}

get client() {
Expand Down
19 changes: 19 additions & 0 deletions src/client/websocket/packets/handlers/WebhooksUpdate.js
@@ -0,0 +1,19 @@
const AbstractHandler = require('./AbstractHandler');
const { Events } = require('../../../../util/Constants');

class WebhooksUpdate extends AbstractHandler {
handle(packet) {
const client = this.packetManager.client;
const data = packet.d;
const channel = client.channels.get(data.channel_id);
if (channel) client.emit(Events.WEBHOOKS_UPDATE, channel);
}
}

/**
* Emitted whenever a guild text channel has its webhooks changed.
* @event Client#webhookUpdate
* @param {TextChannel} channel The channel that had a webhook update
*/

module.exports = WebhooksUpdate;
3 changes: 3 additions & 0 deletions src/util/Constants.js
Expand Up @@ -346,6 +346,7 @@ exports.Events = {
VOICE_STATE_UPDATE: 'voiceStateUpdate',
TYPING_START: 'typingStart',
TYPING_STOP: 'typingStop',
WEBHOOKS_UPDATE: 'webhookUpdate',
DISCONNECT: 'disconnect',
RECONNECTING: 'reconnecting',
ERROR: 'error',
Expand Down Expand Up @@ -414,6 +415,7 @@ exports.ActivityFlags = {
* * VOICE_SERVER_UPDATE
* * RELATIONSHIP_ADD
* * RELATIONSHIP_REMOVE
* * WEBHOOKS_UPDATE
* @typedef {string} WSEventType
*/
exports.WSEvents = {
Expand Down Expand Up @@ -454,6 +456,7 @@ exports.WSEvents = {
VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE',
RELATIONSHIP_ADD: 'RELATIONSHIP_ADD',
RELATIONSHIP_REMOVE: 'RELATIONSHIP_REMOVE',
WEBHOOKS_UPDATE: 'WEBHOOKS_UPDATE',
};

/**
Expand Down

0 comments on commit 4530981

Please sign in to comment.