TypeError at _transformAPIMessageInteractionMetadata

I'm having a strange error and can't seem to find anyone who's had this same problem.
async handleModal(interaction) {
if (interaction.customId === 'quizModal') {
const userInput = interaction.fields.getTextInputValue('answerInput');

const checkAnswer = input => {
return input.toLowerCase() === userInput.toLowerCase();
};

const correctAnswer = quoteOutput.answers.some(checkAnswer);
console.log(correctAnswer);

await interaction.reply({ content: `<@${interaction.user.id}> answered: \`${userInput}\`:
The correct answer is...`, components: [] });
await wait(2000);
if (correctAnswer) {
const winEmbed = new EmbedBuilder()
.setColor(0xFF69B4)
.setTitle('Your quote is:')
.setDescription(`${quoteOutput.quote}
Are you ready to play?`)
.setFooter({ text: '(game won!)' });

await interaction.followUp(`\`${quoteOutput.id.charAt(0).toUpperCase() + quoteOutput.id.slice(1)}\`, YOU WIN!!`);
await initialReply.edit({ embeds: [winEmbed], components: [] });
initialReply = '';
}
else {
const loseEmbed = new EmbedBuilder()
.setColor(0xFF69B4)
.setTitle('Your quote is:')
.setDescription(`${quoteOutput.quote}
Are you ready to play?`)
.setFooter({ text: '(game lost...)' });

await interaction.followUp(`\`${quoteOutput.id.charAt(0).toUpperCase() + quoteOutput.id.slice(1)}\`, YOU LOSE!! BOOO`);
await initialReply.edit({ embeds: [loseEmbed], components: [] });
initialReply = '';
}
}
},
async handleModal(interaction) {
if (interaction.customId === 'quizModal') {
const userInput = interaction.fields.getTextInputValue('answerInput');

const checkAnswer = input => {
return input.toLowerCase() === userInput.toLowerCase();
};

const correctAnswer = quoteOutput.answers.some(checkAnswer);
console.log(correctAnswer);

await interaction.reply({ content: `<@${interaction.user.id}> answered: \`${userInput}\`:
The correct answer is...`, components: [] });
await wait(2000);
if (correctAnswer) {
const winEmbed = new EmbedBuilder()
.setColor(0xFF69B4)
.setTitle('Your quote is:')
.setDescription(`${quoteOutput.quote}
Are you ready to play?`)
.setFooter({ text: '(game won!)' });

await interaction.followUp(`\`${quoteOutput.id.charAt(0).toUpperCase() + quoteOutput.id.slice(1)}\`, YOU WIN!!`);
await initialReply.edit({ embeds: [winEmbed], components: [] });
initialReply = '';
}
else {
const loseEmbed = new EmbedBuilder()
.setColor(0xFF69B4)
.setTitle('Your quote is:')
.setDescription(`${quoteOutput.quote}
Are you ready to play?`)
.setFooter({ text: '(game lost...)' });

await interaction.followUp(`\`${quoteOutput.id.charAt(0).toUpperCase() + quoteOutput.id.slice(1)}\`, YOU LOSE!! BOOO`);
await initialReply.edit({ embeds: [loseEmbed], components: [] });
initialReply = '';
}
}
},
6 Replies
d.js toolkit
d.js toolkit3w 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 OP
YellowLink
YellowLinkOP3w ago
This is a function I have for handling a particular modal submission. It takes a text input in the form of a name, checks if it matches - one of - the correct answer(s), and should do different things depending on whether the person got the answer right. This function used to work verbatim before the 14.16 update (more accurately, the last time it was used was before the update and it worked as intended then).
/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/util/Transformers.js:45
id: messageInteractionMetadata.id,
^

TypeError: Cannot read properties of undefined (reading 'id')
at _transformAPIMessageInteractionMetadata (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/util/Transformers.js:45:36)
at _transformAPIMessageInteractionMetadata (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/util/Transformers.js:52:9)
at Message._patch (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/structures/Message.js:409:34)
at new Message (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/structures/Message.js:52:10)
at GuildMessageManager._add (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/managers/CachedManager.js:58:32)
at GuildMessageManager._add (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/managers/MessageManager.js:38:18)
at MessageCreateAction.handle (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/actions/MessageCreate.js:20:52)
at module.exports [as MESSAGE_CREATE] (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)

Node.js v21.6.2
/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/util/Transformers.js:45
id: messageInteractionMetadata.id,
^

TypeError: Cannot read properties of undefined (reading 'id')
at _transformAPIMessageInteractionMetadata (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/util/Transformers.js:45:36)
at _transformAPIMessageInteractionMetadata (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/util/Transformers.js:52:9)
at Message._patch (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/structures/Message.js:409:34)
at new Message (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/structures/Message.js:52:10)
at GuildMessageManager._add (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/managers/CachedManager.js:58:32)
at GuildMessageManager._add (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/managers/MessageManager.js:38:18)
at MessageCreateAction.handle (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/actions/MessageCreate.js:20:52)
at module.exports [as MESSAGE_CREATE] (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/home/yellowlink/Documents/GitHub/ChaosBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)

Node.js v21.6.2
It now has started throwing this error and ending the terminal process. It breaks specifically after this line:
await interaction.reply({ content: `<@${interaction.user.id}> answered: \`${userInput}\`:
The correct answer is...`, components: [] });
await interaction.reply({ content: `<@${interaction.user.id}> answered: \`${userInput}\`:
The correct answer is...`, components: [] });
d.js toolkit
d.js toolkit3w ago
Make sure you updated to discord.js v14.16.1 or newer. If the error persists, let us know!
YellowLink
YellowLinkOP3w ago
I don't know how to approach this error because none of the listed files are ones I made and know how to deal with. Sorry for using multiple messages, character limit
Mark
Mark3w ago
What version of the library are you using
YellowLink
YellowLinkOP3w ago
okay, I feel real silly now, I updated discord.js and it worked. I swear I tried that sorry for the pointless post lol
Want results from more Discord servers?
Add your server