[Mod] Omit empty fields from [p]userinfo (#1829)

* Hide roles if none are found.

* Clarify about omitted fields in help doc
This commit is contained in:
Kowlin 2018-08-11 05:59:43 +02:00 committed by Toby Harradine
parent 47350328e6
commit 591ed50ac3

View File

@ -1266,7 +1266,14 @@ class Mod:
@commands.command()
@commands.guild_only()
async def userinfo(self, ctx, *, user: discord.Member = None):
"""Shows users's informations"""
"""Shows information for a user.
This includes fields for status, discord join date, server
join date, voice state and previous names/nicknames.
If the user has none of roles, previous names or previous
nicknames, these fields will be omitted.
"""
author = ctx.author
guild = ctx.guild
@ -1306,12 +1313,13 @@ class Mod:
if roles:
roles = ", ".join([x.name for x in roles])
else:
roles = _("None")
roles = None
data = discord.Embed(description=activity, colour=user.colour)
data.add_field(name=_("Joined Discord on"), value=created_on)
data.add_field(name=_("Joined this server on"), value=joined_on)
data.add_field(name=_("Roles"), value=roles, inline=False)
if roles is not None:
data.add_field(name=_("Roles"), value=roles, inline=False)
if names:
data.add_field(name=_("Previous Names"), value=", ".join(names), inline=False)
if nicks: