Skip to content
Advertisement

mention user from string(name#discriminator) discord.py

I have an user in str format, for example:

me#0000

I want to convert it into a member to be able to do:

member.mention

I tried:

MemberConverter()

and:

member = discord.utils.get(message.guild.members, name=user.split("#")[0], discriminator=user.split("#")[1])

both make member NoneType, the name and discriminator are fine.

Advertisement

Answer

If you have both the username and discriminator, the best way to get that member would be like this:

member = message.guild.get_member_named("me#0000")

ALSO: Make sure you have enabled intents in your bot (discord.Intents.all()) and in your application in the Discord Dev Portal

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement