Discord.py: user.display_name returns regular username instead of nickname for self.bot.user

Created on 26 May 2018  路  2Comments  路  Source: Rapptz/discord.py

As the title says. For normal members and other bot accounts when pulled as discord.Member or discord.User, it's working as intended. The issue is for self.bot.user only.

Most helpful comment

I believe this might be a slight misconception - user.display_name will always return the username (it's in there for compatibility with Member). self.bot.user is a user, not a guild member thus there will never be a nickname displayed by self.bot.user.display_name. For a guild-specific nickname, try using guild.me.display_name (rewrite) or server.me.display_name (async).

All 2 comments

I believe this might be a slight misconception - user.display_name will always return the username (it's in there for compatibility with Member). self.bot.user is a user, not a guild member thus there will never be a nickname displayed by self.bot.user.display_name. For a guild-specific nickname, try using guild.me.display_name (rewrite) or server.me.display_name (async).

Thank you for the reply and solution. It was indeed my oversight as to how self.bot.user is without a server context as opposed to member. Allow me to close this issue.

Was this page helpful?
0 / 5 - 0 ratings