gpt4 book ai didi

javascript - 我无法让我的机器人识别 react 并做出响应 (Discord.js)

转载 作者:行者123 更新时间:2023-12-04 07:18:53 29 4
gpt4 key购买 nike

const Discord = require ('discord.js')

module.exports.run = async (client, message, reaction, user) => {

message.channel.send("Press **F** to pay respect!!").then(msg => {msg.react("<:pressf:861646469180948530>")})

const filter = (reaction, user) => {
return reaction.emoji.name === ' === "<:pressf:861646469180948530>' && user.id === message.author.id;

};


const collector = message.createReactionCollector( filter);


collector.on('collect', (reaction, user) => {
if (message.emoji.name === "<:pressf:861646469180948530>"){
message.channel.send("You pay respect!!")
}
})

};

最佳答案

问题是您正在对原始消息设置 react 收集器。尝试等待发送的消息,并接受对此的 react :

module.exports.run = async (client, message, reaction, user) => {
const sentMessage = await message.channel.send('Press **F** to pay respect!!');

sentMessage.react('<:pressf:861646469180948530>');

const filter = (reaction, user) =>
// there was an extra === " here
reaction.emoji.name === '<:pressf:861646469180948530>' &&
user.id === message.author.id;

const collector = sentMessage.createReactionCollector(filter);

collector.on('collect', (reaction, user) => {
if (reaction.emoji.name === '<:pressf:861646469180948530>') {
message.channel.send('You pay respect!!');
}
});
};

关于javascript - 我无法让我的机器人识别 react 并做出响应 (Discord.js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68624504/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com