本文介紹了如何使用 discord.py 獲取不和諧服務器中所有成員的列表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試生成我服務器中所有成員的列表:
I am trying to generate a list of all of the members in my server:
@client.event
async def on_ready():
for guild in client.guilds:
for member in guild.members:
print(member)
但是它只打印自己而不打印其他成員.我寫錯了什么還是我需要對機器人做些什么?
However it is only printing itself and none of the other members. Have I written something wrong or is there something I need to do with the bot?
推薦答案
需要開啟intents.members
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(..., intents=intents)
# Or if you're using `discord.Client`
client = discord.Client(intents=intents)
還要確保在開發者門戶
文檔
這篇關于如何使用 discord.py 獲取不和諧服務器中所有成員的列表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!