【问题标题】:Discord.js: is there a partial to list new reactions on old messages?Discord.js:是否有部分列出对旧消息的新反应?
【发布时间】:2020-06-05 02:54:37
【问题描述】:

channelBackgroundCheck.send(`${reaction.users.cache.last()}, your account is being reviewed. Please standby.`)

当我运行代码并通过对消息做出反应来执行 if 语句时,它会将其发送到频道 undefined, your account is being reviewed. Please standby. 在我删除反应并再次做出反应后,它正确地提到了我的名字。我已经有 2 个部分,我认为他们会涵盖这个 if (reaction.partial) & if (reaction.message.partial)。最初是否可以正确显示做出反应的用户名?

我正在使用 Discord.js 的主版本。这是我的代码:

   if (emoji.name == '✅') {
        if (reaction.partial) {
            try {
                await reaction.fetch();
            } catch (error) {
                console.log('Something went wrong when fetching the reaction: ', error);
            }
        }
        if (reaction.message.partial) {
            // If the message was removed the fetching might result in an API error, which we need to handle
            try {
                await reaction.message.fetch();
            } catch (error) {
                console.log('Something went wrong when fetching the message: ', error);
            }
        }
            message.guild.members.fetch(user.id).then(member => {
                    member.roles.add('679017985905786884');
                    member.roles.remove('678920391863042048');
            const guild = client.guilds.cache.get('678723590631325716')
            const channelBackgroundCheck = guild.channels.cache.get('678746066681724928')
            channelBackgroundCheck.send(`${reaction.users.cache.last()}, your account is being reviewed. Please standby.`)
            const channelFrontexStaff = guild.channels.cache.get('679082070081011773')
            channelFrontexStaff.send(`${reaction.users.cache.last()}, has joined the server. Their account is created on ${user.createdAt.toLocaleDateString("nl-NL")}`)
            const now = new Date();
                now.setMilliseconds(0);
                now.setSeconds(0);
                now.setMinutes(0);
                now.setHours(0);
                console.log(now);
            const accountCreation = user.createdAt;
                accountCreation.setMilliseconds(0);
                accountCreation.setSeconds(0);
                accountCreation.setMinutes(0);
                accountCreation.setHours(0);
                console.log(accountCreation);
            if(now - accountCreation < (86400000 * 7) /* one day multiplied by desired amount of days */) {
                channelFrontexStaff.send(`⚠️  ${reaction.users.cache.last()} has a new account.`)
            }

        });
    }
});

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    是的,您需要为此获取消息数据。这是很好的guide 如何轻松解决您的问题

    【讨论】:

    • 死链接(404)
    猜你喜欢
    • 1970-01-01
    • 2020-08-02
    • 2021-05-14
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 2021-05-26
    • 1970-01-01
    • 2020-11-30
    相关资源
    最近更新 更多