[英]Trying to create a reaction on a message by using its Id. - discord.js
By the tests I made, the emoji to react is fine, but it is reacting to the command message, not the message I specified the Id.通过我所做的测试,响应的表情符号很好,但它响应的是命令消息,而不是我指定 Id 的消息。
module.exports = {
name: 'cargo',
description: 'Give a role to an user by reaction',
execute(message, args) {
const messageId = args.slice(0, 1);
const roleEmoji = args.slice(1);
const fetchMessage = message.channel.fetch(`${messageId}`)
//const roleGive = MessageMentions.roles;
console.log('\x1b[35m%s\x1b[0m','messageId:', messageId,'roleEmoji:', roleEmoji)
message.channel.messages.fetch(`${messageId}`).then(() => message.react(`${roleEmoji}`));
message.channel.send(`${messageId}, ${roleEmoji}`);
}
You were calling react on the wrong message, this should solve your issue.您正在对错误消息做出反应,这应该可以解决您的问题。
module.exports = {
name: 'cargo',
description: 'Give a role to an user by reaction',
execute(message, args) {
const messageId = args.slice(0, 1);
const roleEmoji = args.slice(1);
const fetchMessage = message.channel.fetch(`${messageId}`)
//const roleGive = MessageMentions.roles;
console.log('\x1b[35m%s\x1b[0m','messageId:', messageId,'roleEmoji:', roleEmoji)
message.channel.messages.fetch(`${messageId}`).then(msg => msg.react(`${roleEmoji}`));
message.channel.send(`${messageId}, ${roleEmoji}`);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.