Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda