我正在尝试允许用户根据他们键入的内容添加角色,但只有当他们键入的内容与数组中的内容相同时,它才有效。下面是目前的代码:
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循环时,它停止添加,如果这有任何帮助的话。非常感谢!
发布于 2020-06-09 09:05:48
我做了一些愚蠢的事情,只是删除了角色中的权限标签。我真不敢相信我没有早点这么做
https://stackoverflow.com/questions/62273420
复制相似问题