Get All Members from a Guild in Discord.py

前端 未结 2 1670
野性不改
野性不改 2021-01-14 23:48

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         


        
2条回答
  •  无人及你
    2021-01-15 00:11

    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")
    

提交回复
热议问题