#error getting the value of a embed's field.

27 messages · Page 1 of 1 (latest)

solid saffron
#

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)
}
robust cedarBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
viral hedge
#

an embed has a data property

#

in which the data is stored

solid saffron
# viral hedge in which the data is stored
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)
}
viral hedge
#

show your code

solid saffron
#
const mess = await interaction.channel.messages.fetch({ limit: 1 });
const me = mess.first();
const Ticket_type = me.embeds[0].data.fields[1].value;
viral hedge
#

then that message does not have any embeds

solid saffron
#

it does

#

it has two embeds

viral hedge
#

log embeds

solid saffron
viral hedge
#

log <Message>.embeds

solid saffron
#

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

viral hedge
#

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

solid saffron
#

without storing it

viral hedge
#

set after to 0 when fetching, should work

solid saffron
#

have i to keep const firstmessage = messages.first(); or not?

#

and the limit to 1

viral hedge
#

yes

solid saffron
#

it works