0

I want to send a direct message using a bot to a person who doesn't share a common guild with the bot. For this I need to have the user ID of the person but in my use case I'm only having access to the username + discriminator. Is there a way to obtain the ID using the username?

Something like..


user_id = client.fetch_user("bob#0000")
user=await client.get_user_info(user_id)
await client.send_message(user, "message")

1 Answers1

0

It is impossible for a bot to get a user's ID by only their name and discriminator if it does not share any common guilds. The API does not have any endpoints to do so at the time of writing. The UserConverter in discord.py can only convert by name and discriminator if the user appears in the cache, which is usually not the case if there are no common guilds.

Jonathan Feenstra
  • 2,534
  • 1
  • 15
  • 22