From 8a77e6eb19aac44d5cfb56100db52a84165381f3 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Mon, 31 May 2021 15:32:53 +0200 Subject: [PATCH 1/3] feat: easier guards for channelUpdate --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index b9088e04871e..c6295a54ff82 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2604,7 +2604,7 @@ declare module 'discord.js' { channelCreate: [channel: GuildChannel]; channelDelete: [channel: DMChannel | GuildChannel]; channelPinsUpdate: [channel: Channel | PartialDMChannel, date: Date]; - channelUpdate: [oldChannel: Channel, newChannel: Channel]; + channelUpdate: [oldChannel: DMChannel | GuildChannel, newChannel: DMChannel | GuildChannel]; debug: [message: string]; warn: [message: string]; emojiCreate: [emoji: GuildEmoji]; From e2462d7fc1ff98fcdcfb69dd751bde0f076f8568 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Mon, 31 May 2021 17:08:24 +0200 Subject: [PATCH 2/3] typings: more explicit typings for client events involving channels --- typings/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index c6295a54ff82..a6450c6b1040 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2603,7 +2603,7 @@ declare module 'discord.js' { applicationCommandUpdate: [oldCommand: ApplicationCommand | null, newCommand: ApplicationCommand]; channelCreate: [channel: GuildChannel]; channelDelete: [channel: DMChannel | GuildChannel]; - channelPinsUpdate: [channel: Channel | PartialDMChannel, date: Date]; + channelPinsUpdate: [channel: TextChannel | NewsChannel | DMChannel | PartialDMChannel, date: Date]; channelUpdate: [oldChannel: DMChannel | GuildChannel, newChannel: DMChannel | GuildChannel]; debug: [message: string]; warn: [message: string]; @@ -2646,7 +2646,7 @@ declare module 'discord.js' { roleCreate: [role: Role]; roleDelete: [role: Role]; roleUpdate: [oldRole: Role, newRole: Role]; - typingStart: [channel: Channel | PartialDMChannel, user: User | PartialUser]; + typingStart: [channel: TextChannel | NewsChannel | DMChannel | PartialDMChannel, user: User | PartialUser]; userUpdate: [oldUser: User | PartialUser, newUser: User]; voiceStateUpdate: [oldState: VoiceState, newState: VoiceState]; webhookUpdate: [channel: TextChannel]; From 0fdc96703c82ab6075a07d1ce804ebf497e4ff8b Mon Sep 17 00:00:00 2001 From: almostSouji Date: Mon, 31 May 2021 17:21:48 +0200 Subject: [PATCH 3/3] docs: event doc consistency regarding channel types --- src/client/actions/TypingStart.js | 2 +- src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/actions/TypingStart.js b/src/client/actions/TypingStart.js index 7a35bc3f2055..ebb1bb67de8d 100644 --- a/src/client/actions/TypingStart.js +++ b/src/client/actions/TypingStart.js @@ -40,7 +40,7 @@ class TypingStart extends Action { /** * Emitted whenever a user starts typing in a channel. * @event Client#typingStart - * @param {Channel} channel The channel the user started typing in + * @param {DMChannel|TextChannel|NewsChannel} channel The channel the user started typing in * @param {User} user The user that started typing */ this.client.emit(Events.TYPING_START, channel, user); diff --git a/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js b/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js index 13e6f0faf0c2..4f460d6a1438 100644 --- a/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +++ b/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js @@ -14,7 +14,7 @@ module.exports = (client, { d: data }) => { * Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event, * not much information can be provided easily here - you need to manually check the pins yourself. * @event Client#channelPinsUpdate - * @param {DMChannel|TextChannel} channel The channel that the pins update occurred in + * @param {DMChannel|TextChannel|NewsChannel} channel The channel that the pins update occurred in * @param {Date} time The time of the pins update */ client.emit(Events.CHANNEL_PINS_UPDATE, channel, time);