本文介紹了在 Discord.js 中列出可踢成員的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
所以我正在嘗試清理我的舊服務器,并且我希望我的機器人踢出名為bot"的角色以下的所有人.(并讓每個人都高于它)所以我認為(如果我錯了,請糾正我)將創建一個可踢成員的列表,然后踢每個成員(forEach).但是,我找不到制作此列表的方法.任何幫助,將不勝感激.謝謝!
So I am trying to clean up my old server, and I want my bot to kick everyone below a role named "bot". (and keep everyone above it) So I think (correct me if I am wrong) would be to create a list of kickable members and then kick each one (forEach). However, I can't find a way to make this list. Any help would be appreciated. Thanks!
推薦答案
你可以用 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);
});
這篇關于在 Discord.js 中列出可踢成員的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!