【发布时间】:2020-11-24 17:23:48
【问题描述】:
我正在尝试使用我的 discord.js 机器人为我的 discord 服务器创建一个自己的票务系统。 如果用户使用 ???? 对某个消息做出反应emoji,我想让它先立即删除反应,然后继续。所以基本上反应计数保持在 1(我的机器人中唯一的一个)。 问题是,如果我重新启动机器人并对消息做出反应,它不会删除我的反应,但是当我手动删除它并重试时,它会起作用!
这是我的代码:
client.on("messageReactionAdd", async (messageReaction, user) => {
if (messageReaction.partial) {
try {
await messageReaction.fetch();
} catch (error) {
console.log("couldn't fetch message1", error);
}
}
let msg = messageReaction.message;
if (msg.id === config.support_msg_id) {
const userReactions = msg.reactions.cache.filter(reaction => reaction.users.cache.has(user.id));
try {
for (const reaction of userReactions.values()) {
await reaction.users.remove(user.id);
}
} catch (error) {
console.error('Failed to remove reactions.');
}
}
});
【问题讨论】:
标签: javascript node.js discord discord.js ticket-system