问题
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
The client.wait_for_message doesnt seem to detect the message author in the code as well, any solutions?
回答1:
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
回答2:
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.)
来源:https://stackoverflow.com/questions/53672754/obtaining-username-from-user-id-discord-py