问题
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