RockRom
RockRom

Reputation: 63

Discord.js v13 delete message after a certain amount of time

Up to discord.js v12, my bot would delete messages it posted like this :

message.reply("text")
  .then(msg => {
    message.delete()
    msg.delete({timeout: 5000})    //amount of time I want it to wait in milliseconds
  })
  .catch()

However, now that I updated discord.js modules to v13, the message is deleted instantly.

Is there a new method to do that, or am I doing it wrong ?

Upvotes: 0

Views: 7129

Answers (1)

RockRom
RockRom

Reputation: 63

Turns out that, as stated in the documentation here, msg.delete() does not accept options anymore, meaning the correct code is now this :

message.reply("text")
  .then(repliedMessage => {
    setTimeout(() => repliedMessage.delete(), 5000);
  });
  .catch();

Upvotes: 1

Related Questions