Attempting to react to a message but it is throwing an error

the code in question is
const { EmbedBuilder, MessageFlags } = require("discord.js")

require("dotenv").config()


module.exports = async (interaction, feedback, type) => {
const envMAIN_SERVER = process.env.MAIN_SERVER
const envFEEDBACK_CHANNEL = process.env.FEEDBACK_CHANNEL

const MAIN_SERVER = await interaction.client.guilds.fetch(envMAIN_SERVER)
const FEEDBACK_CHANNEL = await MAIN_SERVER.channels.fetch(envFEEDBACK_CHANNEL)

// const = interaction.options.getString("feedback")
// const = interaction.options.getString("type")
let rating = ``
if (interaction.options.getString("rating") == null) {
rating = "N/A"
}
if (interaction.options.getString("rating")) {
for (let i = 1; i<=4; i+=1) {
rating+=`<star:1426399846503415948> `
}
}
let messageTha
if (type == "bug") {
const embed = new EmbedBuilder()
.setTitle("Issue")
.setAuthor({name: `${interaction.user.username} ยท Feedback`, iconURL: interaction.user.displayAvatarURL()})
.setThumbnail("https://cdn.discordapp.com/attachments/1383280628421759036/1426398881171898400/HoneyBot_Issue.png?ex=68eb14fa&is=68e9c37a&hm=12ddd44910e51d5694e84578ea98a175166c4b32b55fbca17531e548ad1c929f")
.setDescription(feedback)
.addFields(
{name: "Rating", value: rating}
)
.setFooter({text:`${interaction.user.username} | ${interaction.user.id}`})
.setColor("f19700")

messageTha = await FEEDBACK_CHANNEL.send({content:`<@&${process.env.FEEDBACK_PING_ROLE}>`,embeds:[embed]})
} else if (type == "sugg") {
const embed = new EmbedBuilder()
.setTitle("Bot Suggestion")
.setAuthor({name: `${interaction.user.username} ยท Feedback`, iconURL: interaction.user.displayAvatarURL()})
.setThumbnail("https://cdn.discordapp.com/attachments/1383280628421759036/1426398913044283504/HoneyBot_Suggestion.png?ex=68eb1502&is=68e9c382&hm=16c3f0d200a3c6144a15cc3cfbfe5f673f8a097ba40efc10f53546d4c7cb54b7")
.setDescription(feedback)
.addFields(
{name: "Rating", value: rating}
)
.setFooter({text:`${interaction.user.username} | ${interaction.user.id}`})
.setColor("f19700")

messageTha = await FEEDBACK_CHANNEL.send({content:`<@&${process.env.FEEDBACK_PING_ROLE}>`,embeds:[embed]})
} else if (type == "review") {
const embed = new EmbedBuilder()
.setAuthor({name: `${interaction.user.username} ยท Feedback`, iconURL: interaction.user.displayAvatarURL()})
.setTitle("Review")
.setThumbnail("https://cdn.discordapp.com/attachments/1383280628421759036/1426399043784933486/HoneyBot_Review.png?ex=68eb1521&is=68e9c3a1&hm=cc36cc4672e4a5a3b5b75bf6081b5fbadad3130190c90cfd70e48fce0d91e6e1")
.setDescription(feedback)
.addFields(
{name: "Rating", value: rating}
)
.setFooter({text:`${interaction.user.username} | ${interaction.user.id}`})
.setColor("f19700")

messageTha = await FEEDBACK_CHANNEL.send({content:`<@&${process.env.FEEDBACK_PING_ROLE}>`,embeds:[embed]})
}
await messageTha.react("๐Ÿ‘")
await messageTha.react("๐Ÿ‘Ž")
const thread = await messageTha.startThread({
name: `Discussion: Feedback from ${interaction.user.username}`
})
await thread.send({content:`This is a place to discuss the feedback submitted by <@${interaction.user.id}>. Feel free to share your thoughts regarding their ideas!`})

await interaction.reply({content:"> โœ… Your feedback has successfully been submitted.", flags: MessageFlags.Ephemeral})

return thread
}
const { EmbedBuilder, MessageFlags } = require("discord.js")

require("dotenv").config()


module.exports = async (interaction, feedback, type) => {
const envMAIN_SERVER = process.env.MAIN_SERVER
const envFEEDBACK_CHANNEL = process.env.FEEDBACK_CHANNEL

const MAIN_SERVER = await interaction.client.guilds.fetch(envMAIN_SERVER)
const FEEDBACK_CHANNEL = await MAIN_SERVER.channels.fetch(envFEEDBACK_CHANNEL)

// const = interaction.options.getString("feedback")
// const = interaction.options.getString("type")
let rating = ``
if (interaction.options.getString("rating") == null) {
rating = "N/A"
}
if (interaction.options.getString("rating")) {
for (let i = 1; i<=4; i+=1) {
rating+=`<star:1426399846503415948> `
}
}
let messageTha
if (type == "bug") {
const embed = new EmbedBuilder()
.setTitle("Issue")
.setAuthor({name: `${interaction.user.username} ยท Feedback`, iconURL: interaction.user.displayAvatarURL()})
.setThumbnail("https://cdn.discordapp.com/attachments/1383280628421759036/1426398881171898400/HoneyBot_Issue.png?ex=68eb14fa&is=68e9c37a&hm=12ddd44910e51d5694e84578ea98a175166c4b32b55fbca17531e548ad1c929f")
.setDescription(feedback)
.addFields(
{name: "Rating", value: rating}
)
.setFooter({text:`${interaction.user.username} | ${interaction.user.id}`})
.setColor("f19700")

messageTha = await FEEDBACK_CHANNEL.send({content:`<@&${process.env.FEEDBACK_PING_ROLE}>`,embeds:[embed]})
} else if (type == "sugg") {
const embed = new EmbedBuilder()
.setTitle("Bot Suggestion")
.setAuthor({name: `${interaction.user.username} ยท Feedback`, iconURL: interaction.user.displayAvatarURL()})
.setThumbnail("https://cdn.discordapp.com/attachments/1383280628421759036/1426398913044283504/HoneyBot_Suggestion.png?ex=68eb1502&is=68e9c382&hm=16c3f0d200a3c6144a15cc3cfbfe5f673f8a097ba40efc10f53546d4c7cb54b7")
.setDescription(feedback)
.addFields(
{name: "Rating", value: rating}
)
.setFooter({text:`${interaction.user.username} | ${interaction.user.id}`})
.setColor("f19700")

messageTha = await FEEDBACK_CHANNEL.send({content:`<@&${process.env.FEEDBACK_PING_ROLE}>`,embeds:[embed]})
} else if (type == "review") {
const embed = new EmbedBuilder()
.setAuthor({name: `${interaction.user.username} ยท Feedback`, iconURL: interaction.user.displayAvatarURL()})
.setTitle("Review")
.setThumbnail("https://cdn.discordapp.com/attachments/1383280628421759036/1426399043784933486/HoneyBot_Review.png?ex=68eb1521&is=68e9c3a1&hm=cc36cc4672e4a5a3b5b75bf6081b5fbadad3130190c90cfd70e48fce0d91e6e1")
.setDescription(feedback)
.addFields(
{name: "Rating", value: rating}
)
.setFooter({text:`${interaction.user.username} | ${interaction.user.id}`})
.setColor("f19700")

messageTha = await FEEDBACK_CHANNEL.send({content:`<@&${process.env.FEEDBACK_PING_ROLE}>`,embeds:[embed]})
}
await messageTha.react("๐Ÿ‘")
await messageTha.react("๐Ÿ‘Ž")
const thread = await messageTha.startThread({
name: `Discussion: Feedback from ${interaction.user.username}`
})
await thread.send({content:`This is a place to discuss the feedback submitted by <@${interaction.user.id}>. Feel free to share your thoughts regarding their ideas!`})

await interaction.reply({content:"> โœ… Your feedback has successfully been submitted.", flags: MessageFlags.Ephemeral})

return thread
}
7 Replies
d.js toolkit
d.js toolkitโ€ข2mo ago
! Merlington
! MerlingtonOPโ€ข2mo ago
and it is throwing the error
C:\Users\yusuf\Documents\programming projects\discordbots\nouritytrial\src\commands\util\feedback\responses\postFeedback.js:65
await messageTha.react("๐Ÿ‘")
^

TypeError: Cannot read properties of undefined (reading 'react')
at module.exports (C:\Users\yusuf\Documents\programming projects\discordbots\nouritytrial\src\commands\util\feedback\responses\postFeedback.js:65:22)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async module.exports (C:\Users\yusuf\Documents\programming projects\discordbots\nouritytrial\src\commands\util\feedback\responses\approve.js:37:20)
C:\Users\yusuf\Documents\programming projects\discordbots\nouritytrial\src\commands\util\feedback\responses\postFeedback.js:65
await messageTha.react("๐Ÿ‘")
^

TypeError: Cannot read properties of undefined (reading 'react')
at module.exports (C:\Users\yusuf\Documents\programming projects\discordbots\nouritytrial\src\commands\util\feedback\responses\postFeedback.js:65:22)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async module.exports (C:\Users\yusuf\Documents\programming projects\discordbots\nouritytrial\src\commands\util\feedback\responses\approve.js:37:20)
Mafia
Mafiaโ€ข2mo ago
if you log messageTha what do you get?
! Merlington
! MerlingtonOPโ€ข2mo ago
I get undefined
Mafia
Mafiaโ€ข2mo ago
so that is your answer. You have a case that does not set messageTha
! Merlington
! MerlingtonOPโ€ข2mo ago
OH Im stupid I forgot that I renamed the types oopsie thx for ur help tho
d.js toolkit
d.js toolkitโ€ข2mo ago
The thread owner has marked this issue as solved.

Did you find this page helpful?