Reputation: 1812
Does anyone know how to get the discord username (and discriminator) of someone given its ID? This code does not return a username:
userid = '123'
username = bot.get_user_info(userid)
Thank you ! :)
Upvotes: 1
Views: 6759
Reputation: 11232
What is bot
? I guess it's your discord.Client
object? Then, your call to get_user_info
returns an object of class discord.User
. Furthermore, get_user_info
is a coroutine.
You will have to write something like this:
user = await bot.get_user_info(userid)
username = user.name
As @squaswin pointed out in the comments: Keep in mind that await
statements have to be inside async
functions. Otherwise a SyntaxError
will be raised.
Upvotes: 2