Discord.js Delete Single Message

牧云@^-^@ 提交于 2019-12-07 13:25:55

问题


I am currently working on creating a Discord bot using Discord.js, and I want to have a command that you can tell it ||say Hello or something and it will delete your comment, then say what you told it to.

My current code is

client.on('message', message => {
   if (message.content.startsWith("||say ")) {
      message.delete(1000); //Supposed to delete message
      message.channel.send(message.content.slice(5, message.content.length));
   }
});

But this is not working.


回答1:


It turns out that I had the correct code, but my bot had to have moderator permissions.




回答2:


You could've also made the bot send a message then delete 2 instead but if it works i guess that's fine :)



来源:https://stackoverflow.com/questions/45395255/discord-js-delete-single-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!