From 691145b50c56b59e00398bb6d4337c7f6d7b1abf Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Mon, 24 Jul 2023 15:15:26 +0100 Subject: [PATCH 1/2] types(BaseButtonComponentData): narrow `type` --- packages/discord.js/typings/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 766ff2deb2be..bcacc178eabc 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -5807,6 +5807,7 @@ export interface MessageActivity { } export interface BaseButtonComponentData extends BaseComponentData { + type: ComponentType.Button; style: ButtonStyle; disabled?: boolean; emoji?: ComponentEmojiResolvable; From 140af379ddef4e3ad39bbfc5f8198ca7133d95ab Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Mon, 24 Jul 2023 15:15:42 +0100 Subject: [PATCH 2/2] test: fix suddenly broken tests --- packages/discord.js/typings/index.test-d.ts | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 9c9f79938d44..75c7d7f465e3 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -174,6 +174,8 @@ import { ChatInputApplicationCommandData, ApplicationCommandPermissionsManager, GuildOnboarding, + StringSelectMenuComponentData, + ButtonComponentData, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -532,10 +534,10 @@ client.on('messageCreate', async message => { // Check that both builders and builder data can be sent in messages const row = new ActionRowBuilder(); - const buttonsRow: ActionRowData = { + + const rawButtonsRow: ActionRowData = { type: ComponentType.ActionRow, components: [ - new ButtonBuilder(), { type: ComponentType.Button, label: 'test', style: ButtonStyle.Primary, customId: 'test' }, { type: ComponentType.Button, @@ -545,21 +547,34 @@ client.on('messageCreate', async message => { }, ], }; - const selectsRow: ActionRowData = { + + const buttonsRow: ActionRowData = { + type: ComponentType.ActionRow, + components: [new ButtonBuilder()], + }; + + const rawStringSelectMenuRow: ActionRowData = { type: ComponentType.ActionRow, components: [ - new StringSelectMenuBuilder(), { type: ComponentType.StringSelect, - label: 'select menu', options: [{ label: 'test', value: 'test' }], customId: 'test', }, ], }; + const stringSelectRow: ActionRowData = { + type: ComponentType.ActionRow, + components: [new StringSelectMenuBuilder()], + }; + const embedData = { description: 'test', color: 0xff0000 }; - channel.send({ components: [row, buttonsRow, selectsRow], embeds: [embed, embedData] }); + + channel.send({ + components: [row, rawButtonsRow, buttonsRow, rawStringSelectMenuRow, stringSelectRow], + embeds: [embed, embedData], + }); }); client.on('messageDelete', ({ client }) => expectType>(client));