diff options
| author | 2019-12-18 09:13:09 -0800 | |
|---|---|---|
| committer | 2019-12-18 09:13:09 -0800 | |
| commit | adcafc3a2adeffc5998274d9dc73728178d64721 (patch) | |
| tree | 06b217b597a9294ada7c70c90271059865276c4b | |
| parent | Constants: add voice state emotes (diff) | |
ModLog: change voice state embed icon and colour
Use a red icon when leaving or mute/deafened. Use a green icon when
joining or unmuted/undeafened. Use a blue icon when changing channels or
any other possible change.
| -rw-r--r-- | bot/cogs/moderation/modlog.py | 27 | 
1 files changed, 22 insertions, 5 deletions
| diff --git a/bot/cogs/moderation/modlog.py b/bot/cogs/moderation/modlog.py index 98d9c546f..8dea44efe 100644 --- a/bot/cogs/moderation/modlog.py +++ b/bot/cogs/moderation/modlog.py @@ -782,15 +782,32 @@ class ModLog(Cog, name="ModLog"):          # "overwrite" values_changed; in practice there will never even be anything to overwrite.          diff_values = {**diff.get("values_changed", {}), **diff.get("type_changes", {})} +        icon = Icons.voice_state_blue +        colour = Colour.blurple()          changes = [] +          for attr, values in diff_values.items(): -            if not attr:  # Not sure why, but it happens +            if not attr:  # Not sure why, but it happens.                  continue -            attr = attr[5:]  # Remove "root." prefix +            old = values["old_value"] +            new = values["new_value"] + +            attr = attr[5:]  # Remove "root." prefix.              attr = VOICE_STATE_ATTRIBUTES.get(attr, attr.replace("_", " ").capitalize()) -            changes.append(f"**{attr}:** `{values['old_value']}` **→** `{values['new_value']}`") +            changes.append(f"**{attr}:** `{old}` **→** `{new}`") + +            # Set the embed icon and colour depending on which attribute changed. +            if any(name in attr for name in ("Channel", "deaf", "mute")): +                if new is None or new is True: +                    # Left a channel or was muted/deafened. +                    icon = Icons.voice_state_red +                    colour = Colours.soft_red +                elif old is None or old is True: +                    # Joined a channel or was unmuted/undeafened. +                    icon = Icons.voice_state_green +                    colour = Colours.soft_green          if not changes:              return @@ -799,8 +816,8 @@ class ModLog(Cog, name="ModLog"):          message = f"**{member}** (`{member.id}`)\n{message}"          await self.send_log_message( -            icon_url=Icons.user_update, -            colour=Colour.blurple(), +            icon_url=icon, +            colour=colour,              title="Voice state updated",              text=message,              thumbnail=member.avatar_url_as(static_format="png"), | 
