From 56b5b7ee820c8be36c6d7de0abedf1753cc591dd Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:58:29 +0100 Subject: [PATCH] types(MessageOptions): fix components being optional (#6005) --- typings/index.d.ts | 2 +- typings/index.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 9aea995c4..bf72bc203 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3728,7 +3728,7 @@ declare module 'discord.js' { type MessageActionRowComponentResolvable = MessageActionRowComponent | MessageActionRowComponentOptions; interface MessageActionRowOptions extends BaseMessageComponentOptions { - components?: MessageActionRowComponentResolvable[]; + components: MessageActionRowComponentResolvable[]; } interface MessageActivity { diff --git a/typings/index.ts b/typings/index.ts index cf71854b8..cd5df0a07 100644 --- a/typings/index.ts +++ b/typings/index.ts @@ -5,7 +5,9 @@ import { Collection, Intents, Message, + MessageActionRow, MessageAttachment, + MessageButton, MessageEmbed, Permissions, Serialized, @@ -380,6 +382,26 @@ client.on('message', ({ channel }) => { channel.send({ another: 'property' }); }); +client.on('interaction', async interaction => { + if (!interaction.isCommand()) return; + + void new MessageActionRow(); + + const button = new MessageButton(); + + const actionRow = new MessageActionRow({ components: [button] }); + + await interaction.reply({ content: 'Hi!', components: [actionRow] }); + + await interaction.reply({ content: 'Hi!', components: [[button]] }); + + // @ts-expect-error + void new MessageActionRow({}); + + // @ts-expect-error + await interaction.reply({ content: 'Hi!', components: [button] }); +}); + client.login('absolutely-valid-token'); // Test type transformation: