typings: make channelId non-nullable on MessageComponentInteraction (#6600)

This commit is contained in:
Suneet Tipirneni
2021-09-08 08:42:05 -04:00
committed by GitHub
parent c62823e43d
commit 8cc3885739
3 changed files with 16 additions and 0 deletions

View File

@@ -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}

1
typings/index.d.ts vendored
View File

@@ -1318,6 +1318,7 @@ export class MessageComponentInteraction extends Interaction {
public readonly component: MessageActionRowComponent | Exclude<APIMessageComponent, APIActionRowComponent> | null;
public componentType: Exclude<MessageComponentType, 'ACTION_ROW'>;
public customId: string;
public channelId: Snowflake;
public deferred: boolean;
public ephemeral: boolean | null;
public message: Message | APIMessage;

View File

@@ -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<Snowflake | null>(interaction.guildId);
assertType<Snowflake | null>(interaction.channelId);
assertType<GuildMember | APIInteractionGuildMember | null>(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<Snowflake>(interaction.channelId);
}
});
client.login('absolutely-valid-token');