亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

創建角色 discord.js 時角色覆蓋

創建角色 discord.js 時角色覆蓋

撒科打諢 2023-05-19 14:57:16
當我的機器人加入一個新公會時,它會創建一個角色并設置覆蓋。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 回答

?
當年話下

TA貢獻1890條經驗 獲得超9個贊

要將角色與在線成員分開顯示,可以使用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.



查看完整回答
反對 回復 2023-05-19
  • 1 回答
  • 0 關注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號