创建角色discord.js时角色覆盖

时间:2020-10-18 17:18:11

标签: javascript 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);
  });

我有2个问题:
是否可以将此角色移到列表顶部或至少移到附近?
我将如何继续与在线成员分开显示此角色?

1 个答案:

答案 0 :(得分:0)

要与在线成员分开显示角色,可以使用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.
相关问题