Modals

button.showModal(
new Modal()
.setCustomId("test")
.setTitle("This is a test modal")
.addComponents(
new MessageActionRow()
.addComponents(
new TextInputComponent()
.setCustomId("test")
.setLabel("This is a test input.")
.setStyle("SHORT")
)
)
);
button.showModal(
new Modal()
.setCustomId("test")
.setTitle("This is a test modal")
.addComponents(
new MessageActionRow()
.addComponents(
new TextInputComponent()
.setCustomId("test")
.setLabel("This is a test input.")
.setStyle("SHORT")
)
)
);
gives a type error
Argument of type 'MessageActionRow<MessageActionRowComponent, MessageActionRowComponentResolvable, APIActionRowComponent<APIMessageActionRowComponent>>' is not assignable to parameter of type 'MessageActionRow<TextInputComponent, ModalActionRowComponentResolvable, APIActionRowComponent<APITextInputComponent>> | (Required<...> & MessageActionRowOptions<...>)'.
Argument of type 'MessageActionRow<MessageActionRowComponent, MessageActionRowComponentResolvable, APIActionRowComponent<APIMessageActionRowComponent>>' is not assignable to parameter of type 'MessageActionRow<TextInputComponent, ModalActionRowComponentResolvable, APIActionRowComponent<APITextInputComponent>> | (Required<...> & MessageActionRowOptions<...>)'.
Any idea what I'm doing wrong?
5 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs2y ago
In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
treble/luna
treble/luna2y ago
v14, but same principle for v13
Vigintillion
VigintillionOP2y ago
ah thank you
treble/luna
treble/luna2y ago
yw
Want results from more Discord servers?
Add your server