mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
feat: handle and forward WEBHOOKS_UPDATE events (#2762)
* src: Handle WEBHOOK_UPDATE events * Commit rename of 77' Or adding the letter S * I missed this * Properly do this now Typos everywhere * Typings * refactor: remove now unnecessary guild variable
This commit is contained in:
@@ -47,6 +47,7 @@ class WebSocketPacketManager {
|
|||||||
this.register(WSEvents.MESSAGE_REACTION_ADD, require('./handlers/MessageReactionAdd'));
|
this.register(WSEvents.MESSAGE_REACTION_ADD, require('./handlers/MessageReactionAdd'));
|
||||||
this.register(WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemove'));
|
this.register(WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemove'));
|
||||||
this.register(WSEvents.MESSAGE_REACTION_REMOVE_ALL, require('./handlers/MessageReactionRemoveAll'));
|
this.register(WSEvents.MESSAGE_REACTION_REMOVE_ALL, require('./handlers/MessageReactionRemoveAll'));
|
||||||
|
this.register(WSEvents.WEBHOOKS_UPDATE, require('./handlers/WebhooksUpdate'));
|
||||||
}
|
}
|
||||||
|
|
||||||
get client() {
|
get client() {
|
||||||
|
|||||||
19
src/client/websocket/packets/handlers/WebhooksUpdate.js
Normal file
19
src/client/websocket/packets/handlers/WebhooksUpdate.js
Normal file
@@ -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;
|
||||||
@@ -249,6 +249,7 @@ exports.Events = {
|
|||||||
VOICE_BROADCAST_UNSUBSCRIBE: 'unsubscribe',
|
VOICE_BROADCAST_UNSUBSCRIBE: 'unsubscribe',
|
||||||
TYPING_START: 'typingStart',
|
TYPING_START: 'typingStart',
|
||||||
TYPING_STOP: 'typingStop',
|
TYPING_STOP: 'typingStop',
|
||||||
|
WEBHOOKS_UPDATE: 'webhookUpdate',
|
||||||
DISCONNECT: 'disconnect',
|
DISCONNECT: 'disconnect',
|
||||||
RECONNECTING: 'reconnecting',
|
RECONNECTING: 'reconnecting',
|
||||||
ERROR: 'error',
|
ERROR: 'error',
|
||||||
@@ -290,6 +291,7 @@ exports.Events = {
|
|||||||
* * VOICE_STATE_UPDATE
|
* * VOICE_STATE_UPDATE
|
||||||
* * TYPING_START
|
* * TYPING_START
|
||||||
* * VOICE_SERVER_UPDATE
|
* * VOICE_SERVER_UPDATE
|
||||||
|
* * WEBHOOKS_UPDATE
|
||||||
* @typedef {string} WSEventType
|
* @typedef {string} WSEventType
|
||||||
*/
|
*/
|
||||||
exports.WSEvents = keyMirror([
|
exports.WSEvents = keyMirror([
|
||||||
@@ -324,6 +326,7 @@ exports.WSEvents = keyMirror([
|
|||||||
'VOICE_STATE_UPDATE',
|
'VOICE_STATE_UPDATE',
|
||||||
'TYPING_START',
|
'TYPING_START',
|
||||||
'VOICE_SERVER_UPDATE',
|
'VOICE_SERVER_UPDATE',
|
||||||
|
'WEBHOOKS_UPDATE',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
7
typings/index.d.ts
vendored
7
typings/index.d.ts
vendored
@@ -140,7 +140,8 @@ declare module 'discord.js' {
|
|||||||
public on(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this;
|
public on(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this;
|
||||||
public on(event: 'typingStart' | 'typingStop', listener: (channel: Channel, user: User) => void): this;
|
public on(event: 'typingStart' | 'typingStop', listener: (channel: Channel, user: User) => void): this;
|
||||||
public on(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this;
|
public on(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this;
|
||||||
public once(event: 'voiceStateUpdate', listener: (oldState: VoiceState, newState: VoiceState) => void): this;
|
public on(event: 'voiceStateUpdate', listener: (oldState: VoiceState, newState: VoiceState) => void): this;
|
||||||
|
public on(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this;
|
||||||
public on(event: string, listener: Function): this;
|
public on(event: string, listener: Function): this;
|
||||||
|
|
||||||
public once(event: 'channelCreate' | 'channelDelete', listener: (channel: Channel) => void): this;
|
public once(event: 'channelCreate' | 'channelDelete', listener: (channel: Channel) => void): this;
|
||||||
@@ -171,6 +172,7 @@ declare module 'discord.js' {
|
|||||||
public once(event: 'typingStart' | 'typingStop', listener: (channel: Channel, user: User) => void): this;
|
public once(event: 'typingStart' | 'typingStop', listener: (channel: Channel, user: User) => void): this;
|
||||||
public once(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this;
|
public once(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this;
|
||||||
public once(event: 'voiceStateUpdate', listener: (oldState: VoiceState, newState: VoiceState) => void): this;
|
public once(event: 'voiceStateUpdate', listener: (oldState: VoiceState, newState: VoiceState) => void): this;
|
||||||
|
public once(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this;
|
||||||
public once(event: string, listener: Function): this;
|
public once(event: string, listener: Function): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1976,7 +1978,8 @@ declare module 'discord.js' {
|
|||||||
| 'PRESENCE_UPDATE'
|
| 'PRESENCE_UPDATE'
|
||||||
| 'VOICE_STATE_UPDATE'
|
| 'VOICE_STATE_UPDATE'
|
||||||
| 'TYPING_START'
|
| 'TYPING_START'
|
||||||
| 'VOICE_SERVER_UPDATE';
|
| 'VOICE_SERVER_UPDATE'
|
||||||
|
| 'WEBHOOKS_UPDATE';
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user