Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

403
Views
Discord.JS Message Edit

I want to edit the message over and over again. So I made variable

this.msgRef = await channel.send({ embeds: [embedMessage] });

If I want to edit I use

this.msgRef.edit(...)

If the bot for some reason disconnects, he will lose msgReference. Because of that, I saved it to DB. How to create a message again because Message (object) in Discord.JS have a private constructor?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to get the message again, you can simply fetch the channel's messages every time you bot connects (on the ready event for example) like so

client.on('ready', () =>{
  const messages = await channel.messages.fetch()
  client.msgRef = messages.find(msg => msg.author.id === client.user.id
    && msg.embeds[0]
   // Etc.. Add as many conditions to make sure you choose the right message
);
})

This way, use client.msgRef.edit(...) whenever you want.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!