Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ def __getattr__(cls, name):
if cls.subsection is not None:
return _CONFIG_YAML[cls.section][cls.subsection][name]
return _CONFIG_YAML[cls.section][name]
except KeyError:
except KeyError as e:
dotted_path = '.'.join(
(cls.section, cls.subsection, name)
if cls.subsection is not None else (cls.section, name)
)
log.critical(f"Tried accessing configuration variable at `{dotted_path}`, but it could not be found.")
raise
# Only an INFO log since this can be caught through `hasattr` or `getattr`.
log.info(f"Tried accessing configuration variable at `{dotted_path}`, but it could not be found.")
raise AttributeError(repr(name)) from e

def __getitem__(cls, name):
return cls.__getattr__(name)
Expand Down Expand Up @@ -280,6 +281,8 @@ class Emojis(metaclass=YAMLGetter):
badge_partner: str
badge_staff: str
badge_verified_bot_developer: str
verified_bot: str
bot: str

defcon_shutdown: str # noqa: E704
defcon_unshutdown: str # noqa: E704
Expand Down
5 changes: 5 additions & 0 deletions bot/exts/info/information.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ async def create_user_embed(self, ctx: Context, user: FetchedMember) -> Embed:
if on_server and user.nick:
name = f"{user.nick} ({name})"

if user.public_flags.verified_bot:
name += f" {constants.Emojis.verified_bot}"
elif user.bot:
name += f" {constants.Emojis.bot}"

badges = []

for badge, is_set in user.public_flags:
Expand Down
2 changes: 2 additions & 0 deletions config-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ style:
badge_partner: "<:partner:748666453242413136>"
badge_staff: "<:discord_staff:743882896498098226>"
badge_verified_bot_developer: "<:verified_bot_dev:743882897299210310>"
bot: "<:bot:812712599464443914>"
verified_bot: "<:verified_bot:811645219220750347>"

defcon_shutdown: "<:defcondisabled:470326273952972810>"
defcon_unshutdown: "<:defconenabled:470326274213150730>"
Expand Down
2 changes: 2 additions & 0 deletions tests/bot/exts/info/test_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ async def test_create_user_embed_uses_string_representation_of_user_in_title_if_
"""The embed should use the string representation of the user if they don't have a nick."""
ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=1))
user = helpers.MockMember()
user.public_flags = unittest.mock.MagicMock(verified_bot=False)
user.nick = None
user.__str__ = unittest.mock.Mock(return_value="Mr. Hemlock")
user.colour = 0
Expand All @@ -297,6 +298,7 @@ async def test_create_user_embed_uses_nick_in_title_if_available(self):
"""The embed should use the nick if it's available."""
ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=1))
user = helpers.MockMember()
user.public_flags = unittest.mock.MagicMock(verified_bot=False)
user.nick = "Cat lover"
user.__str__ = unittest.mock.Mock(return_value="Mr. Hemlock")
user.colour = 0
Expand Down