我正在尝试生成我服务器中所有成员的列表:
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模板网!