Discord.py get user object from id/tag

后端 未结 3 843
南方客
南方客 2021-01-14 22:11

So i\'m trying to get a user object from an id or tag, however i am using a user account not a bot account so i cant use get_user_info() Is there any way to

相关标签:
3条回答
  • 2021-01-14 22:36

    If you know the user id, I suggest using bot.get_user(user_id) instead.

    0 讨论(0)
  • 2021-01-14 22:39

    If you're using commands, you can use a converter

    @bot.command(pass_sontext=True)
    async def mycommand(ctx, user: discord.User):
        # user is a User object
    

    Other wise, you can use Client.get_all_members to get all Member objects you can see.

    from discord.utils import get
    
    user = get(bot.get_all_members(), id="1234")
    if user:
        # found
    else:
        # Not found
    
    0 讨论(0)
  • 2021-01-14 22:41

    You can use:

    ctx.message.server.get_member("id") or message.server.get_member("id")
    

    This will return you a discord.Member object.

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