【问题标题】:How can I put 2 discord ids inside a if(message.author.id !=) statement如何在 if(message.author.id !=) 语句中放入 2 个不和谐 ID
【发布时间】:2022-02-15 09:19:19
【问题描述】:

您好,我一直在尝试运行此代码并尝试对其进行多次重新编码,但每当我尝试将 2 个 ID 放入 if(message.author.id != ownerid) 返回时 message.channel.send("您无权访问此命令");它只注册 1 个 id 这是我当前的代码:

client.on('message', message => {
    if (message.content === prefix + 'listservers') {
    if(message.author.id != ownerid && altid) return message.channel.send("You don't have access to this command");
//rest of the code

}})

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    您有几个不同的选择。这是我的做法,使用数组和Array.includes()

    const allowedUsers = ["user id 1", "user id 2"]
    
    client.on('message', message => {
        if (message.content === prefix + 'listservers') {
        if(!allowedUsers.includes(message.author.id)) return message.channel.send("You don't have access to this command");
    //rest of the code
    
    }})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 1970-01-01
      • 2015-08-18
      • 1970-01-01
      相关资源
      最近更新 更多