[英]How to fix react is not a function discord.js?
I've been struggling with this issue for quite a while, so I want to make my bot react with the emoji when someone reacts with on the same message.我已经为这个问题苦苦挣扎了很长一段时间,所以我想让我的机器人在有人对同一条消息做出反应时对表情符号做出反应。 However, I'm getting this error whenever I react with.但是,每当我做出反应时,我都会收到此错误。 Error: TypeError: Cannot read property 'react' of undefined
错误: TypeError: Cannot read property 'react' of undefined
Any kind of help is really appreciated, thanks.任何形式的帮助都非常感谢,谢谢。
client.on('messageReactionAdd', async (reaction,user) => {
if (reaction.emoji.name === '🔒') {
const msg = reaction.message.channel.id
await msg.react('🚫')
} else if(reaction.emoji.name === '🚫'){
const channelId = reaction.message.channel.id;
if (channelId){
channelId.delete();
}
}
});
You are setting msg
to the message's ID (which is a string), not to the message object.您将msg
设置为消息的 ID(它是一个字符串),而不是消息 object。 Replace the assignment with this one:用这个替换作业:
const msg = reaction.message;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.