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.