Skip to content
Advertisement

I can’t edit a message from discord.js bot

I want to make a countdown timer that uses a command /timer minutes seconds where the user chooses how long the countdown will be. I want the bot to send the timer as a reply to the command which I’ve successfully done. However, I also want the message to update along with the timer.

I can console.log the timer and it works but I can’t figure out how to make the bot edit its own message. I have tried to just simply edit the bots’ message without the timer but with no success.

Code:

JavaScript

Advertisement

Answer

What you are looking for is interaction.editReply() to update the interaction message after an x amount of time using your timer. This is an example of how you can use it:

JavaScript

This also works if ephemeral is set to true. Note that this is a raw example, and you should adjust the code by your needs.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement