【问题标题】:Make a list of kickable members in Discord.js在 Discord.js 中列出可踢成员
【发布时间】:2020-10-23 01:57:32
【问题描述】:

所以我正在尝试清理我的旧服务器,并且我希望我的机器人将所有人踢到名为“bot”的角色之下。 (并让每个人都高于它)所以我认为(如果我错了,请纠正我)将创建一个可踢成员的列表,然后踢每个人(forEach)。但是,我找不到制作此列表的方法。任何帮助,将不胜感激。谢谢!

【问题讨论】:

  • 什么是“那个角色”。

标签: javascript discord discord.js


【解决方案1】:

您可以将角色职位与Role.comparePositionTo进行比较

// <guild> is a placeholder for the guild object
const role = <guild>.roles.cache.find(r => r.name === "bot") // get the role

<guild>.members.cache.each((member) => {
 const highest = member.roles.highest; // get the member's highest role
 
 // if the member's highest role is lower than the specified role, kick them
 if (role.comparePositionTo(highest) > 0)
  member.kick().catch(console.error);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-10
    • 2020-09-15
    • 2020-12-28
    • 2021-06-01
    • 1970-01-01
    • 2021-06-26
    • 2021-06-03
    • 2021-11-13
    相关资源
    最近更新 更多