Finding A User By Discord Discrim Via Python
Once again, I'm into Discord bot coding. This time, I'm trying to make a way to find a user by it's Discrim. Getting the user by it's Discrim, would easly allow to do another thing
Solution 1:
Firstly, you should not be using a discrim to find a user. IDs are unique, discrims are not.
Discrims are given to each member to help determine who is who when two members share the same name (i.e. test#0001 and test#0002 are different people)
Anyway, while you cannot find a single specific user by discrims, you can find a list of all the users who share a discrim by using Client.get_all_members
p = client.get_all_members()
found_members = filter(lambda m: m.discriminator==DiscrimIguess[0], p)
If you also have a username you can narrow that list down to a single member and then get the ID from that.
member = discord.utils.get(found_members, name=username)
id = member.id
This method only works for finding members who share a server with the bot. To find users who do not share a server with the bot, you must have an ID already for `Client.get_user_info'
Post a Comment for "Finding A User By Discord Discrim Via Python"