久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何列出來自特定服務器的所有成員?

How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
本文介紹了如何列出來自特定服務器的所有成員?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的代碼是

const list = client.guilds.find("id", "335507048017952771")
       for (user of list.users){
         console.log(user[1].username);
       }

這實際上沒有任何作用.沒有錯誤或任何東西.

This does literally nothing. There is no error or anything.

我只想讓機器人找到一個服務器,然后記錄來自該服務器的所有成員.

I just want the bot to find a server and then log all members from said server.

顯示所有連接的用戶 Discord.js 這個問題的答案沒有一點也幫不上我.我確實嘗試使用 message.guild.users 但這也沒有做任何事情.似乎在 Discord 上找不到任何內容.js 網站 來幫助我.

Displaying all connected users Discord.js The answers in this question didn't really help me at all. I did try using message.guild.users but that also did nothing. Can't seem to find anything on the Discord.js site to help me either.

推薦答案

首先,不要使用.find("id", "335507048017952771"),你應該使用.get("335507048017952771"),正如它在 discord.js 文檔.

Firstly, don't use .find("id", "335507048017952771"), you should be using .get("335507048017952771"), as it says on the discord.js documentation.

Discord.js 中使用的所有集合都使用它們的 id 屬性進行映射,如果你想通過 id 查找,你應該使用 get 方法.有關詳細信息,請參閱 MDN.p>

All collections used in Discord.js are mapped using their id property, and if you want to find by id you should use the get method. See MDN for details.

一個 Guild 沒有 users 屬性,因為它有一個 members 屬性,返回 Collection.現在獲取 username 從每個成員你可以從 user 屬性.因此,您需要遍歷 GuildMember 的集合,并獲取 <GuildMember>.user.username.

A Guild does not have a users property, where as it has a members property, which returns a Collection of GuildMembers. Now to get the username from each member you can obtain that from the user property of the GuildMember. So, you will need to iterate through the collection of GuildMembers, and get the <GuildMember>.user.username.

有幾種方法可以做到這一點,我將使用 forEach() 方法.結果如下:

There are several ways to do this, I will be using the forEach() method. Here's what that would look like as a result:

// Get the Guild and store it under the variable "list"
const list = client.guilds.get("335507048017952771"); 

// Iterate through the collection of GuildMembers from the Guild getting the username property of each member 
list.members.forEach(member => console.log(member.user.username)); 

這篇關于如何列出來自特定服務器的所有成員?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
Discord.js Delete Single Message(Discord.js 刪除單個消息)
主站蜘蛛池模板: 久久中文字幕视频 | 一区二区三区四区视频 | 国产精品美女久久久久av爽 | 中文字幕在线一区二区三区 | 99这里有精品| 欧美成人精品一区二区 | 久久久久久亚洲精品 | 在线观看中文字幕 | 在线观看av的网站 | 黄色a一级 | 91在线观 | 在线网站免费观看18 | 午夜视频在线看 | 五月婷婷综合激情 | 久久精品视频网 | 成人黄色免费视频 | 国产伦精品一区二区三区视频黑人 | 亚洲免费黄色 | 午夜精品福利视频 | 日韩在线视频一区 | 午夜国产在线观看 | 国产毛片毛片毛片 | 丁香av | 谁有毛片网站 | 男女在线视频 | 麻豆tv在线观看 | 深夜福利网址 | 69人人 | 国产精品理论片 | 99久久久国产精品 | 欧美爱爱网 | 亚洲国产成人在线 | 日韩在线免费视频 | 国产黄色av | 日本少妇中文字幕 | 精品久久久久久久久久久 | 91福利视频导航 | 国产在线成人 | 五月天激情综合 | 日韩中文字幕视频 | 特大黑人巨交吊性xxxx视频 |