簡體   English   中英

Discord.JS | 顯示具有特定角色的用戶

[英]Discord.JS | Display Users who have a specific roles

我的名字是塔娜或海倫。 因此,我試圖在用戶具有特定角色時將他添加到嵌入中,就像這個示例機器人一樣? 我應該怎么做,或者你能幫我寫代碼嗎? 非常感謝!!

在此處輸入圖像描述

如果我沒看錯,你希望它只有具有特定角色的用戶嗎? 好吧,這里是 go。

client.on("message", msg => {
//<property> can be replaced with role id, to find by id, with role name, to find by name, etc.
var allUsers = [];
msg.guild.members.fetch(); //cache users
msg.guild.members.cache.forEach(m => {
 if(m.roles.cache.find(r => r.<property> === "whatever")) allUsers.push(m);
})
})

這樣,數組allUsers最終將擁有您選擇的角色的所有用戶。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM