0

Expectation: The bot deletes the user command and replies

Result: The bot replies but does not delete the user command

bot.on('message', msg => {

 // Broken
 if(msg.content === 'replace me'){
    
    msg.reply(' replaced');
    msg.delete(500);

  } 

})

Thank you in advance,

meow-meow-meow
  • 508
  • 2
  • 10
  • 26
  • 1
    Does this answer your question? [Make discord bot (js) echo message, but removing the command from the message?](https://stackoverflow.com/questions/53838838/make-discord-bot-js-echo-message-but-removing-the-command-from-the-message) – Dshiz Oct 24 '20 at 18:10
  • 1
    @Dshiz thanks for the suggestion but that's a slightly different issue, Elitezen has resolved my issue below – meow-meow-meow Oct 24 '20 at 18:57

1 Answers1

1

From what I understand, when you say 'user command' you are referring to the message of the user. In that case the issue is with msg.delete(500).

.delete() takes a timeout object as a parameter. Change your code to this

msg.reply(' replaced');
msg.delete({timeout: 500});

For an instant delete with no delay use

msg.delete()
Elitezen
  • 6,551
  • 6
  • 15
  • 29