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 toolkitā€¢16mo 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 docsā€¢16mo 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/lunaā€¢16mo ago
v14, but same principle for v13
Vigintillion
Vigintillionā€¢16mo ago
ah thank you
treble/luna
treble/lunaā€¢16mo ago
yw
Want results from more Discord servers?
Add your server