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

95
Views
Edit message with interval

I have code that should edit a discord message per each execution. Everything seems to be work fine, but when I add interval functionality(to execute it code every minute) it couldn't edit bot message anymore:

call:

setInterval(function () { var data = getData(response, list); editMessage(data) }, 60000)

function with message edit

function editMessage(data) {
    client.on('ready', () => {
        client.guilds.cache.get('server').channels.cache.get('channel').messages.fetch('message').then(message => {
            message.edit('new message content');
        }).catch(err => {
            console.error(err);
        });;
    });
}

So I can receive the data inside editMessage function, but anything that goes inside of client.on('ready', () => {... can't be engaged with interval function. What could be the case?

I'm using Discord.js 12 version.

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

0

Just for the record, I made this work in a different approach. I've wrapped the setInterval function inside of client.on and it works as intended.

        client.on('ready', () => {
            client.guilds.cache.get('server').channels.cache.get('channel').messages.fetch('message').then(message => {
                setInterval(function () {
                message.edit('new message content');
                console.log('new message content')
            }, 1 * 30000);
            }).catch(err => {
                console.error(err);
            });;
        });
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!