简体   繁体   English

努力从 discord.js 中删除特定用户的反应。 说删除未定义

[英]Struggling to remove a reaction from specific user in discord.js. Says remove not defined

I am trying to make pages work by reacting left or right.我试图通过向左或向右做出反应来使页面正常工作。 That works but I can't seem to undo the users reaction.这行得通,但我似乎无法撤消用户的反应。 It tells me remove is undefined它告诉我删除未定义

.then(sentEmbed => {
            sentEmbed.react("⬅️"),
                sentEmbed.react("➡️")
            const filterLeft = (reaction, user) => reaction.emoji.name === '⬅️' && user.id === author;
            const filterRight = (reaction, user) => reaction.emoji.name === '➡️' && user.id === author;
            const collectorLeft = sentEmbed.createReactionCollector(filterLeft, { time: 15000 });
            const collectorRight = sentEmbed.createReactionCollector(filterRight, { time: 15000 });
            collectorRight.on('collect', r => {

                currentMessage = sentEmbed.id,
                    client.channels.cache.get(channel).send(currentMessage),
                    sentEmbed.reaction.remove(author),

I supposed your are using discord.js v12.我想你正在使用 discord.js v12。 If yes, the reactions collected is now using caching.如果是,则收集的反应现在正在使用缓存。 So you need to replace:所以你需要更换:

sentEmbed.reaction.remove(author); by sentEmbed.reaction.users.remove(author);通过sentEmbed.reaction.users.remove(author);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM