首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我正在编写我的第一个discord机器人,创建有限制的角色很奇怪。

我正在编写我的第一个discord机器人,创建有限制的角色很奇怪。
EN

Stack Overflow用户
提问于 2020-06-09 09:02:40
回答 1查看 7关注 0票数 0

我正在尝试允许用户根据他们键入的内容添加角色,但只有当他们键入的内容与数组中的内容相同时,它才有效。下面是目前的代码:

代码语言:javascript
复制
    let guild = client.guilds.cache.get(guildID)
    let user = receivedMessage.author.username
    let fullCommand = receivedMessage.content.substr(0) // Remove the leading exclamation mark
    let splitCommand = fullCommand.split(" ") // Split the message up in to pieces for each space
    let role = splitCommand.slice(1).toString()
      let timezones = ['utc', 'utc-1', 'utc-2', 'utc-3', 'utc-4', 'utc-5', 'utc-6', 'utc-7', 'utc-8',                            'utc-9', 'utc-10', 'utc-11', 'utc+1', 'utc+2', 'utc+3', 'utc+4', 'utc+5', 'utc+6', 
                       'utc+7', 'utc+8', 'utc+9', 'utc+10', 'utc+11'] 
    let word = "hi"
    for (let i = 0; i < timezones.length; i++) {
      word = timezones[i].toString()
      if (role == word) {
        receivedMessage.guild.roles.create({
           data: {
           name: role,
           color: 'RED'
           }
        })
        console.log(user + " added " + role + " as their role")
      }
    }
  }

可能有一些我没有注意到的简单的错误。但是,当我添加for循环时,它停止添加,如果这有任何帮助的话。非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2020-06-09 09:05:48

我做了一些愚蠢的事情,只是删除了角色中的权限标签。我真不敢相信我没有早点这么做

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62273420

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档