有没有办法比较两个成员的排名? [英] Is there a way to compare two members' rankings?

查看:33
本文介绍了有没有办法比较两个成员的排名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Discord机器人.我正在编写警告命令,但是我需要一个代码来比较两个成员(角色)的排名.示例:一个人高于B个人.如果B人试图警告A人,则漫游器会说您不能警告此人".如果A人试图警告B人,则机器人会警告B人.

I have a Discord bot. I am coding warn command but I need a code to compare two members' (role) rankings. Example: A person is higher than B person. If B person tries to warn A person, bot says 'You can not warn this person.'. If A person tries to warn B person, bot warns B person.

该怎么做?

推荐答案

获取每个成员的最高职位并比较其计算出的职位

通过获取 GuidMember 最高角色并获得计算出的职位,我们可以使用此值与其他成员的最高职位的计算出的职位进行比较,以查看谁的职位更高服务器的角色管理器.

By getting a GuidMember's Highest Role and getting that Role's Calculated Position, we can use this value to compare with other member's highest role's calculated positions to see who's higher up according to the server's role manager.

// I'll assume you already have the data for both members (memberA and memberB)
let rankingA = memberA.highestRole.calculatedPosition;
let rankingB = memberB.highestRole.calculatedPosition;

if (rankingA > rankingB) {
  // apply warning
} else {
  // reject warning
}

注意:

  • .highestRole 将返回角色对象本身.
  • .calculatedPosition 将返回一个整数,值越大表示排名越高.
  • .highestRole will return the role object itself.
  • .calculatedPosition will return an integer, higher value means higher ranking.

这篇关于有没有办法比较两个成员的排名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆