嘿,这是我下面的代码,它可以正常工作,但是我只获得了一次与我聊天(在私人聊天中)的用户。
@client.command()
async def hi(ctx):
with open('users.txt','w') as f:
for member in ctx.guild.members:
print("{},{}".format(member,member.id), file=f,)
print("done")
答案 0 :(得分:2)
您可能需要调用fetch_members
来从Discord API更新客户端内部缓存:
@client.command()
async def hi(ctx):
with open('users.txt','w') as f:
async for member in ctx.guild.fetch_members(limit=None):
print("{},{}".format(member,member.id), file=f,)
print("done")
答案 1 :(得分:0)
您是否启用了 Intent,如果没有,请启用它们并尝试。