DankCoder
DankCoder

Reputation: 369

Obtaining username from user id | discord.py

Well I have been working with databases for a while with discord in order to obtain major lists of user id's in a queue, although I am having problem's obtaining the user from user id as it returns none

For Example


members = list(privateduos[matchid])
user = discord.User(id=int(members[0]))
await client.say("Say `test` " + str(user))
await client.wait_for_message(content="test", author=user)

This is the Output

Output:

The client.wait_for_message doesnt seem to detect the message author in the code as well, any solutions?

Upvotes: 3

Views: 29144

Answers (2)

hulyce
hulyce

Reputation: 470

The method client.get_user_info is deprecated since the last Migration, you should use Client.fetch_user() instead

See this link for the details : https://discordpy.readthedocs.io/en/latest/migrating.html

Upvotes: 4

WQYeo
WQYeo

Reputation: 4071

Use await client.get_user_info(members[0])

From there on, (assuming that you have allocated the returned value to user) you can do user.name to obtain the username.
(Or fetch other information about the user as stated here.)

Upvotes: 2

Related Questions