简体   繁体   English

如何让 Discord Bot 删除用户命令并将其替换为回复

[英]How do I get a Discord Bot to delete a user command and replace it with a reply

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,先感谢您,

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) .在那种情况下,问题出在msg.delete(500)上。

.delete() takes a timeout object as a parameter. .delete()将超时 object 作为参数。 Change your code to this将您的代码更改为此

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

For an instant delete with no delay use立即删除,不延迟使用

msg.delete()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM