admin管理员组文章数量:1201375
I've been trying to make a discord bot using discord.js, but I can't seem to find any documentation on how to create a role that works in 2018. All the ones I can find that work, no longer work as they have removed the referenced function. In there is no mention of a createRole("role", "roleName"); type function.
If anyone could help that would be great!
I've been trying to make a discord bot using discord.js, but I can't seem to find any documentation on how to create a role that works in 2018. All the ones I can find that work, no longer work as they have removed the referenced function. In https://discord.js.org/#/docs/main/stable/class/Role there is no mention of a createRole("role", "roleName"); type function.
If anyone could help that would be great!
Share Improve this question asked Nov 15, 2018 at 23:33 6IU6IU 1352 gold badges2 silver badges7 bronze badges2 Answers
Reset to default 18Guild.createRole does not appear to exist in 2020. Instead, it seems that you can get a reference to a RoleManager object via the property Guild.roles, and then call create on the RoleManager object:
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=roles https://discord.js.org/#/docs/main/stable/class/RoleManager?scrollTo=create
From their docs:
// Create a new role with data and a reason
guild.roles.create({
data: {
name: 'Super Cool People',
color: 'BLUE',
},
reason: 'we needed a role for Super Cool People',
})
.then(console.log)
.catch(console.error);
The class Role
does not have the method to create a new role, you must look at the Guild
class for that. Here is a link to the documentation for the method: https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=createRole. Feel free to comment back if you have any questions!
Edit: As of discord.js v12, createRole
no longer exists, please refer to cecomp64's answer above on creating new roles with the new RoleManager
object.
本文标签: javascriptHow to create a role with discordjsStack Overflow
版权声明:本文标题:javascript - How to create a role with discord.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738586971a2101485.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论