I'm trying to setup a bug report system. I have the token system and everything for it, however I need to know how to have the bot edit a message when it is reacted to by a user with a particular role, which for this sake is named 'Debugger'
The event you want to listen to is client.messageReactionAdd
. Be aware, that it will not listen to non-cached messages. To listen to older messages, you must enable partials , like so:
//top of your code
const client = new Discord.Client({partials: [`MESSAGE`, `CHANNEL`, `REACTION`]});
.
.
.
This will allow you to receive events for partial messages. In order to get full message from partial, you need to fetch it:
client.on('messageReactionAdd', async msgReaction => {
let msg = msgReaction.message;
//note that messageReactionAdd event returns MessageReaction object, not Message.
//this line makes it simpler to write code.
if (msg.partial) await msg.fetch().catch();
//
//rest of your reaction handler goes here
//
});
You will be able to figure out the rest by reading the documentation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.