#Getting display_name from user ID

1 messages · Page 1 of 1 (latest)

neon furnace
#

currently i get error saying NoneType has no attribute display_name :(

zenith pilot
#

Well NoneType would mean that your variable isn’t a Member or User, so you’ll need to check how you’re attempting to fetch the user to begin with

neon furnace
#
ctx.guild.get_member(id)
#

this is for a command, it generates leaderboard for an xp system

#

and currently it displays username with tags, but I want it to show the display name

zenith pilot
#

Yeah but if it’s complaining that it’s NoneType, then you didn’t actually fetch the user for some reason. A more complete code snippet (enclosed in code blocks, or in a gist or other pastebin type link) would be helpful

neon furnace
zenith pilot
#

Okay, so presumably name is a Member object; it’s using str conversion here which is why it shows up as User#Discriminator

What about name.mention? That way your output will always be the user’s current display name

neon furnace
zenith pilot
#

Put it in an embed and they won’t get tagged. Alternatively, there’s an “allowed_mentions” option for send that won’t ping users; check the docs for exact syntax