Message correction privilege error discord bot

Viewed 21

When the code works, the message 'Cannot edit a message authorized by another user' appears. How can I edit the message that the bot wrote?

client.on('messageCreate', async (message) => { // When a message is created
        if (message.author.bot) return;
    if(message.content === '!ping') { // If the message content is "!ping"
      let timecc = 10*60
      await message.reply("⏳"+parseInt((timecc / 60)/60)+"h"+parseInt((timecc / 60)%60)+"m"+(timecc % 60)+"start")
      var timer = setInterval(() => {
          timecc -= 1
          message.edit({ content: "⏳"+parseInt((timecc / 60)/60)+"h"+parseInt((timecc / 60)%60)+"m"+(timecc % 60)+"s" })
          .catch(console.error);
          if (timecc === 0) {
              clearInterval(timer);
              message.edit({ content: "⌛"+"time out" })
              .catch(console.error);
              
              
            }   
}, 1000)
1 Answers

message is the message that emitted the listener, the user's message.

To reference the bot's response you must assign the promise.

const botMsg = await message.reply(...);

botMsg.edit(...)
Related