Discord.js从特定用户ID中删除消息

Discord.js从特定用户ID中删除消息,discord.js,Discord.js,因此,我的代码有一些问题,我正在尝试让message.author.id与常量中的id列表匹配,然后执行一些操作 const blacklisted = ["644298972420374528", "293534327805968394", "358478352467886083"]; if (message.author.id === blacklisted) { message.delete() const blacklistedMSG =

因此,我的代码有一些问题,我正在尝试让message.author.id与常量中的id列表匹配,然后执行一些操作

    const blacklisted = ["644298972420374528", "293534327805968394", "358478352467886083"];
    if (message.author.id === blacklisted) {
        message.delete()
        const blacklistedMSG = new Discord.RichEmbed()
            .setColor('#ff0000')
            .setTitle('Blacklisted')
            .setDescription(`You are currently Blacklisted. This means you cannot send messages in Any server with this bot.`)
            .setTimestamp()
            .setFooter(copyright);
        message.author.send(blacklistedMSG).then(msg => {msg.delete(30000)})
    }
当我有它这样的时候,它什么也不做,而且控制台中也没有关于它的错误。但如果代码是这样的:

if (message.author.id === "644298972420374528") {
        message.delete()
        const blacklistedMSG = new Discord.RichEmbed()
            .setColor('#ff0000')
            .setTitle('Blacklisted')
            .setDescription(`You are currently Blacklisted. This means you cannot send messages in Any server with this bot.`)
            .setTimestamp()
            .setFooter(copyright);
        message.author.send(blacklistedMSG).then(msg => {msg.delete(30000)})
    }

它工作并向用户发送嵌入消息,并删除用户发送的消息。不知道发生了什么事。提前感谢。

您正在与数组进行直接比较,而不是检查message.author.id是否在数组中

而不是

if (message.author.id === blacklisted)
试一试

if (blacklisted.includes(message.author.id))