创建角色时覆盖角色discord.js [英] role overwrites when creating a role discord.js
本文介绍了创建角色时覆盖角色discord.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我的机器人加入新的行会时,它会创建一个角色&;设置覆盖。
client.on("guildCreate", async guild => {
guild.roles.create({
data: {
name: "Billy 🤩", //sets the role name
color: "#e5f7b2", //sets the color of the role
permissions: 8 //sets the roles permissions to administrator
}
}).then(role => guild.member(client.user).roles.add(role)).catch(console.error);
});
我有两个问题:是否可以将此角色移到列表的顶部或至少移到接近的位置?
我如何继续将此角色与在线成员分开显示?
推荐答案
若要将角色与联机成员分开显示,可以使用Role#setHoist
方法。
Role.setHoist(true);
您不能将角色移动到角色层次结构中机器人最高角色的上方。
我建议您获得您的机器人的最高角色,获得其位置,并相应地设置您的角色的位置。
const Role = Guild.roles.cache.get("1234567890123456"); // The role you want to update.
const HighestRole = Guild.me.roles.highest; // Your bot's highest role in the Guid.
Role.setPosition(HighestRole.position - 1); // Setting the role's position right before your HighestRole.
这篇关于创建角色时覆盖角色discord.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文