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 :
undefined
undefined
node:events:497
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read properties of undefined (reading 'spliceFields')
    at Client.<anonymous> (C:\Users\const\Documents\Discord\Bots\Silas Sombrelune\src\index.js:84:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:402:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v21.5.0


This is how i imported the embed :
const { raidmessage, raidembed } = require('./commands/Community/raid.js')
// raidembed = embed
// raidmessage = raidembed message sent by command reply with embeds: [raidembed]


The two "undefined" at the start of the error message are from :
  client.on('interactionCreate', async (interaction) => {
     // [...]
     console.log(raidembed)
     console.log(raidmessage)
     // [...]
  }


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.
Was this page helpful?