From 8cc3885739127ebc7023b6358ed0259ba7527250 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Wed, 8 Sep 2021 08:42:05 -0400 Subject: [PATCH] typings: make `channelId` non-nullable on `MessageComponentInteraction` (#6600) --- src/structures/MessageComponentInteraction.js | 6 ++++++ typings/index.d.ts | 1 + typings/tests.ts | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/src/structures/MessageComponentInteraction.js b/src/structures/MessageComponentInteraction.js index 5ac774b75..d905823c3 100644 --- a/src/structures/MessageComponentInteraction.js +++ b/src/structures/MessageComponentInteraction.js @@ -14,6 +14,12 @@ class MessageComponentInteraction extends Interaction { constructor(client, data) { super(client, data); + /** + * The id of the channel this interaction was sent in + * @type {Snowflake} + * @name MessageComponentInteraction#channelId + */ + /** * The message to which the component was attached * @type {Message|APIMessage} diff --git a/typings/index.d.ts b/typings/index.d.ts index 65fbd87e9..192c52528 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1318,6 +1318,7 @@ export class MessageComponentInteraction extends Interaction { public readonly component: MessageActionRowComponent | Exclude | null; public componentType: Exclude; public customId: string; + public channelId: Snowflake; public deferred: boolean; public ephemeral: boolean | null; public message: Message | APIMessage; diff --git a/typings/tests.ts b/typings/tests.ts index 64f89a973..f4f52c067 100644 --- a/typings/tests.ts +++ b/typings/tests.ts @@ -1,3 +1,4 @@ +import { APIInteractionGuildMember } from 'discord-api-types'; import { ApplicationCommand, ApplicationCommandChoicesData, @@ -565,6 +566,10 @@ client.on('messageCreate', message => { }); client.on('interaction', async interaction => { + assertType(interaction.guildId); + assertType(interaction.channelId); + assertType(interaction.member); + if (!interaction.isCommand()) return; void new MessageActionRow(); @@ -583,6 +588,10 @@ client.on('interaction', async interaction => { // @ts-expect-error await interaction.reply({ content: 'Hi!', components: [button] }); + + if (interaction.isMessageComponent()) { + assertType(interaction.channelId); + } }); client.login('absolutely-valid-token');