Isaac
Isaac

Reputation: 45

discord.py: Can you get the name of a user that's not in a server with your bot from their id?

I have seen discord bots that have the ability to get info(like the name) of users from their id that aren't even in any servers with that bot, and I was wondering if this is possible in discord.py. I know about

client.get_user(id)

but if the user isn't in any servers with the bot it won't work. Can you do this in discord.py?

Upvotes: 1

Views: 3791

Answers (1)

BrainDead
BrainDead

Reputation: 795

You can use the API call fetch_user

user = await client.fetch_user(user_id)

Stick to that link (official documentation) and you won't be wasting time on trivial setbacks like this.

Upvotes: 2

Related Questions