Get All Members from a Guild in Discord.py

前端 未结 2 1666
野性不改
野性不改 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")
    
    0 讨论(0)
  • 2021-01-15 00:20

    Do you have Intents enabled, if not, enable them and try.

    0 讨论(0)
提交回复
热议问题