Modals in Node-Red using Discord JS

A little offtopic but its based on discord.js, i hope to find some support here anyways. In node red i try to show a modal with text input in response to a slash command. for this i took the example from the webpage and modified it to fit into node red, here is my code:
// Create the modal
const modal = new discordjsBuilders.ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');

// Add components to modal

// Create the text input components
const favoriteColorInput = new discordjsBuilders.TextInputBuilder()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(discordApiTypesV9.TextInputStyle.Short);

const hobbiesInput = new discordjsBuilders.TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
// Paragraph means multiple lines of text.
.setStyle(discordApiTypesV9.TextInputStyle.Paragraph);

// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new discordjsBuilders.ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new discordjsBuilders.ActionRowBuilder().addComponents(hobbiesInput);

// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);

// Show the modal to the user
msg.interactionObject.showModal(modal);
// Create the modal
const modal = new discordjsBuilders.ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');

// Add components to modal

// Create the text input components
const favoriteColorInput = new discordjsBuilders.TextInputBuilder()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(discordApiTypesV9.TextInputStyle.Short);

const hobbiesInput = new discordjsBuilders.TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
// Paragraph means multiple lines of text.
.setStyle(discordApiTypesV9.TextInputStyle.Paragraph);

// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new discordjsBuilders.ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new discordjsBuilders.ActionRowBuilder().addComponents(hobbiesInput);

// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);

// Show the modal to the user
msg.interactionObject.showModal(modal);
Last line produces this error: TypeError: Cannot read properties of undefined (reading 'rest') The msg.interactionObject is a copy of the interaction object from the discord.js examples callbacks. I modified the node red version to not send deferReply() too early (before my own flow code comes), basically here: https://github.com/Markoudstaal/node-red-contrib-discord-advanced/blob/6dedf30e2f88c616ac28992b733dbff37b23796a/discord/discordInteraction.js#L58 still i dont understand the error i get, ideas?
GitHub
node-red-contrib-discord-advanced/discord/discordInteraction.js at ...
Recieve, send, edit and delete Discord messages in node-red. - Markoudstaal/node-red-contrib-discord-advanced
4 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
sp00ktober
sp00ktober3mo ago
I see. Tho as you can see in the source code i linked, that third party library passes down the interaction object from djs to my code where the issue then arrises. Thats why i posted here.
chewie 🌈
chewie 🌈3mo ago
Still, that library seems to interfere with discord.js, thus we can't really reliably give you support. You should refer to their support instead. They have a discord linked in the readme.
sp00ktober
sp00ktober3mo ago
Ye i am on there but its a very silent community sadly. I understand that you will not give support here, worth a try tho.