Importing embed and message variables from another file.
Hi, i am trying to make a button that never expire, so im using the method of doing and even handler inside client.on in index.js
The issue is that the button edits an embed message from a command reply.
When i try to export the embed variable from the command file and do embed.spliceFields(), i get this error :
This is how i imported the embed :
The two "undefined" at the start of the error message are from :
So i assume the error is from how I import my variables... Could you help me please ?
Feel free to ping me.
Tell me if you need to see some code, and what part you need.
11 Replies
- 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!and how are those embeds defined
and where do you export them
also if you're just listening for buttons, use <ButtonInteraction>.message
no need to export, you can access the embeds there
in index.js
from ./commands/Community/raid.js
Thats importing
importing and exporting is basic js
And you dont even need it here since you can access the message from the ButtonInteraction
so i could do :
before:
after:
right ? if i understood well what you said
embeds returns an array
and you can just ise <Interaction>.update to edit the message
okay
thanks 👍
How do i get the fields in the embed ?
ik this is basic js but i forgot how to do it (i tried embed.fields but it returns undefined).
or is it embed.data.fields ?
embeds returns an array
You should know how to get items from the array
If not, i recommend brushing up on your js knowledge, #rules 3 #resources
👍