Reputation: 31
Hey this is my following code and it works, but I only get the users with whom I chatted(in private chat) once.
@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")
Upvotes: 3
Views: 13648
Reputation: 60984
You might need to call fetch_members
to update the clients internal cache from the 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")
Upvotes: 4