types(MessageOptions): fix components being optional (#6005)

This commit is contained in:
Rodry
2021-07-03 08:58:29 +01:00
committed by GitHub
parent 0dc5dd5808
commit 56b5b7ee82
2 changed files with 23 additions and 1 deletions

2
typings/index.d.ts vendored
View File

@@ -3728,7 +3728,7 @@ declare module 'discord.js' {
type MessageActionRowComponentResolvable = MessageActionRowComponent | MessageActionRowComponentOptions;
interface MessageActionRowOptions extends BaseMessageComponentOptions {
components?: MessageActionRowComponentResolvable[];
components: MessageActionRowComponentResolvable[];
}
interface MessageActivity {

View File

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