error getting the value of a embed's field.

In this ticket sistem when a ticket is closed it gets a specific value of the first field of the embed message that the bot sends when the ticket is opened. Code: https://sourceb.in/jy4GvIfhrO Code Error:
TypeError: Cannot read properties of undefined (reading 'value')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
<rejected> TypeError: Cannot read properties of undefined (reading 'value')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
TypeError: Cannot read properties of undefined (reading 'value')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
<rejected> TypeError: Cannot read properties of undefined (reading 'value')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
17 Replies
d.js toolkit
d.js toolkit6mo 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
treble/luna
treble/luna6mo ago
an embed has a data property in which the data is stored
Massicraft
Massicraft6mo ago
TypeError: Cannot read properties of undefined (reading 'data')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
<rejected> TypeError: Cannot read properties of undefined (reading 'data')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
TypeError: Cannot read properties of undefined (reading 'data')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
<rejected> TypeError: Cannot read properties of undefined (reading 'data')
at Object.run (/Users/Desktop/New Emeral Bot/src/components/modals/Tmoda.js:20:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
treble/luna
treble/luna6mo ago
show your code
Massicraft
Massicraft6mo ago
const mess = await interaction.channel.messages.fetch({ limit: 1 });
const me = mess.first();
const Ticket_type = me.embeds[0].data.fields[1].value;
const mess = await interaction.channel.messages.fetch({ limit: 1 });
const me = mess.first();
const Ticket_type = me.embeds[0].data.fields[1].value;
treble/luna
treble/luna6mo ago
then that message does not have any embeds
Massicraft
Massicraft6mo ago
it does it has two embeds
treble/luna
treble/luna6mo ago
log embeds
Massicraft
Massicraft6mo ago
?
treble/luna
treble/luna6mo ago
log <Message>.embeds
Massicraft
Massicraft6mo ago
ok oh it doesn't log the right embed it seems like it doesn't fetch the right message the first message of the channel
treble/luna
treble/luna6mo ago
that is expected your above code will just fetch the last message you can store the id of the message, or iirc you can specify after and set it to 0
Massicraft
Massicraft6mo ago
and how to fetch the first msg without storing it
treble/luna
treble/luna6mo ago
set after to 0 when fetching, should work
Massicraft
Massicraft6mo ago
have i to keep const firstmessage = messages.first(); or not? and the limit to 1
treble/luna
treble/luna6mo ago
yes
Massicraft
Massicraft6mo ago
it works ty