【发布时间】:2021-01-04 16:16:58
【问题描述】:
我试图让它在discord.js 中创建一个角色并将其提供给用户,但我似乎收到了这个错误:
UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes.
这是我的代码:
let d = msg.guild.roles.create({
data: {
name: '{:robot: Bot Developer}',
color: 'ff00aa',
permissions: 'ADMINISTRATOR',
},
});
msg.member.roles.add(d);
【问题讨论】:
-
尝试做
msg.member.roles.add(d.id) -
问题是您在角色完全创建之前添加了它。使用
async msg.guild.roles.create(...)或使用.then()语句 -
这些都不起作用@OctagonalT
标签: javascript node.js discord discord.js