检查discord角色是否在另一个角色之上

Check if discord role is above another role

我的一个机器人有问题,我想检查机器人角色是否高于其他角色,我试过了

message.guild.roles.array()

是的,它确实有效。但是,它的顺序不正确,我无法检查该角色是否高于另一个角色。谁能告诉我如何检查机器人角色是否高于其他角色?谢谢

我发现我不想遍历所有角色,所以我只是检查了我正在比较的 2 个角色的位置

let role = message.mentions.roles.first();
let botrole = message.guild.roles.find("name", "Mobile Friendly")
if(role.position > botrole.position){
    return await message.channel.send("I can't access that role, place me above other roles that you want me to manage.")
}