Using Modals with CommandInteraction

When attempting to use Modals with interactions (specifically slash commands), tsc is throwing errors..? Code, copy pasted from the guide (both examples)
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');

// TODO: Add components to modal...

await interaction.showModal(modal);
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');

// TODO: Add components to modal...

await interaction.showModal(modal);
where interaction is a CommandInteraction<'cached'> TS error:
Argument of type 'ModalBuilder' is not assignable to parameter of type 'Modal | ModalOptions'.
Type 'ModalBuilder' is missing the following properties from type 'Modal': customId, title, spliceComponents
Argument of type 'ModalBuilder' is not assignable to parameter of type 'Modal | ModalOptions'.
Type 'ModalBuilder' is missing the following properties from type 'Modal': customId, title, spliceComponents
Tried calling toJSON and accessing the data prop, neither work. Relevant versions:
"@discordjs/builders": "^0.15.0",
"@discordjs/rest": "^0.5.0",
"discord-api-types": "^0.36.1",
"discord.js": "^13.8.1",
"@discordjs/builders": "^0.15.0",
"@discordjs/rest": "^0.5.0",
"discord-api-types": "^0.36.1",
"discord.js": "^13.8.1",
5 Replies
amy
amy2y ago
bump oops never saw this reply what sort of API is that? do you just pass an object to the constructor? (also why does the guide showcase this if it isnt even functional)
Squid
Squid2y ago
You may be looking at a part of the guide which has been updated to v14
Squid
Squid2y ago
The fully v13 guide is located at https://v13.discordjs.guide/
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
amy
amy2y ago
apparently so would have been nice to know that & document that in the changelogs but w/e
Squid
Squid2y ago
It's in <#769862166131245066> at the moment