Skip to content

Conversation

jb3
Copy link
Member

@jb3 jb3 commented Aug 14, 2020

Introduces new information into the !user command showing user badges & statuses on all different Discord platforms as well as switching our headers out for embed fields.

Resolves #1047.

Screenshot 2020-08-14 at 21 20 59

@jb3 jb3 requested a review from a team as a code owner August 14, 2020 20:22
@jb3 jb3 requested review from eivl and kwzrd and removed request for a team August 14, 2020 20:22
@ghost ghost added the needs 2 approvals label Aug 14, 2020
@AtieP
Copy link
Contributor

AtieP commented Aug 14, 2020

That looks neat!

@jb3
Copy link
Member Author

jb3 commented Aug 14, 2020

Updated with status info
image

@jb3 jb3 added a: frontend Related to output and formatting a: moderation Related to community moderation functionality: (moderation, defcon, verification) t: feature New feature or request labels Aug 14, 2020
Comment on lines 243 to 247
badges = ""

for badge, is_set in user.public_flags:
if is_set and (emoji := getattr(constants.Emojis, f"badge_{badge}")):
badges += emoji + " "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat way to use walrus. But I think you want to specify a default for getattr. This way can raise.

I'd probably personally make badges a list & then join the elements on a " ", but this is fine too.

Comment on lines 232 to 235
emoji = ""
if activity.emoji:
if not activity.emoji.id:
emoji += activity.emoji.name + " "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the activity.emoji.id check here to filter custom emoji? I think it could use an in-line comment. It's a little indirect.

Comment on lines 187 to 197
@staticmethod
def status_to_emoji(status: Status) -> str:
"""Convert a Discord status into the relevant emoji."""
if status is Status.offline:
return constants.Emojis.status_offline
elif status is Status.dnd:
return constants.Emojis.status_dnd
elif status is Status.idle:
return constants.Emojis.status_idle
else:
return constants.Emojis.status_online
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using a dictionary to define this mapping? This is probably fine, but it feels a little unnatural to me.

Copy link
Member

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are very nice enhancements. I'm surprised there's no premium or boost info, but that can be saved for another time.

Comment on lines +296 to +297
for field_name, field_content in fields:
embed.add_field(name=field_name, value=field_content, inline=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great refactor.

Copy link
Contributor

@kwzrd kwzrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG to the M.

@ghost ghost removed the needs 1 approval label Aug 23, 2020
@kwzrd kwzrd merged commit f97a5a6 into master Aug 23, 2020
@kwzrd kwzrd deleted the joseph/enhanced-user-command branch August 23, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: frontend Related to output and formatting a: moderation Related to community moderation functionality: (moderation, defcon, verification) t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extended user command

4 participants