Repository: python-discord/bot

Issue:
Don't consider colorless roles for the `!user` embed color
A user with any colorless roles such as `Voice Verified` results in the `!user` embed having a black color (rather than blurple), as shown below.

![Screenshot](https://user-images.githubusercontent.com/37779854/113498668-54178980-94cc-11eb-8ca6-e0e14a128039.png)

This should just be an easy fix to a minor visual problem just by replacing this line:

https://github.com/python-discord/bot/blob/c94fdb0fa5db711236ea02b5bb269e5db906c1a8/bot/exts/info/information.py#L287


Discussion:
Sounds good, thanks for the issue @bsoyka. Would you like to submit a Pull Request? 
Sure, @Akarys42! Please assign this one to me and I should be able to get it done sometime in the next few days.
Awesome! If you have any question, feel free to ask in `#dev-contrib`!

Resolving patch:
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py
--- a/bot/exts/info/information.py
+++ b/bot/exts/info/information.py
@@ -284,7 +284,7 @@ async def create_user_embed(self, ctx: Context, user: FetchedMember) -> Embed:
             embed.add_field(name=field_name, value=field_content, inline=False)
 
         embed.set_thumbnail(url=user.avatar_url_as(static_format="png"))
-        embed.colour = user.top_role.colour if roles else Colour.blurple()
+        embed.colour = user.colour if user.colour != Colour.default() else Colour.blurple()
 
         return embed
 


Test patch:
diff --git a/tests/bot/exts/info/test_information.py b/tests/bot/exts/info/test_information.py
--- a/tests/bot/exts/info/test_information.py
+++ b/tests/bot/exts/info/test_information.py
@@ -283,6 +283,7 @@ async def test_create_user_embed_uses_string_representation_of_user_in_title_if_
         user = helpers.MockMember()
         user.nick = None
         user.__str__ = unittest.mock.Mock(return_value="Mr. Hemlock")
+        user.colour = 0
 
         embed = await self.cog.create_user_embed(ctx, user)
 
@@ -298,6 +299,7 @@ async def test_create_user_embed_uses_nick_in_title_if_available(self):
         user = helpers.MockMember()
         user.nick = "Cat lover"
         user.__str__ = unittest.mock.Mock(return_value="Mr. Hemlock")
+        user.colour = 0
 
         embed = await self.cog.create_user_embed(ctx, user)
 
@@ -311,10 +313,9 @@ async def test_create_user_embed_ignores_everyone_role(self):
         """Created `!user` embeds should not contain mention of the @everyone-role."""
         ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=1))
         admins_role = helpers.MockRole(name='Admins')
-        admins_role.colour = 100
 
         # A `MockMember` has the @Everyone role by default; we add the Admins to that.
-        user = helpers.MockMember(roles=[admins_role], top_role=admins_role)
+        user = helpers.MockMember(roles=[admins_role], colour=100)
 
         embed = await self.cog.create_user_embed(ctx, user)
 
@@ -332,12 +333,11 @@ async def test_create_user_embed_expanded_information_in_moderation_channels(
         ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=50))
 
         moderators_role = helpers.MockRole(name='Moderators')
-        moderators_role.colour = 100
 
         infraction_counts.return_value = ("Infractions", "expanded infractions info")
         nomination_counts.return_value = ("Nominations", "nomination info")
 
-        user = helpers.MockMember(id=314, roles=[moderators_role], top_role=moderators_role)
+        user = helpers.MockMember(id=314, roles=[moderators_role], colour=100)
         embed = await self.cog.create_user_embed(ctx, user)
 
         infraction_counts.assert_called_once_with(user)
@@ -367,11 +367,10 @@ async def test_create_user_embed_basic_information_outside_of_moderation_channel
         ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=100))
 
         moderators_role = helpers.MockRole(name='Moderators')
-        moderators_role.colour = 100
 
         infraction_counts.return_value = ("Infractions", "basic infractions info")
 
-        user = helpers.MockMember(id=314, roles=[moderators_role], top_role=moderators_role)
+        user = helpers.MockMember(id=314, roles=[moderators_role], colour=100)
         embed = await self.cog.create_user_embed(ctx, user)
 
         infraction_counts.assert_called_once_with(user)
@@ -407,12 +406,11 @@ async def test_create_user_embed_uses_top_role_colour_when_user_has_roles(self):
         ctx = helpers.MockContext()
 
         moderators_role = helpers.MockRole(name='Moderators')
-        moderators_role.colour = 100
 
-        user = helpers.MockMember(id=314, roles=[moderators_role], top_role=moderators_role)
+        user = helpers.MockMember(id=314, roles=[moderators_role], colour=100)
         embed = await self.cog.create_user_embed(ctx, user)
 
-        self.assertEqual(embed.colour, discord.Colour(moderators_role.colour))
+        self.assertEqual(embed.colour, discord.Colour(100))
 
     @unittest.mock.patch(
         f"{COG_PATH}.basic_user_infraction_counts",
@@ -422,7 +420,7 @@ async def test_create_user_embed_uses_blurple_colour_when_user_has_no_roles(self
         """The embed should be created with a blurple colour if the user has no assigned roles."""
         ctx = helpers.MockContext()
 
-        user = helpers.MockMember(id=217)
+        user = helpers.MockMember(id=217, colour=discord.Colour.default())
         embed = await self.cog.create_user_embed(ctx, user)
 
         self.assertEqual(embed.colour, discord.Colour.blurple())
@@ -435,7 +433,7 @@ async def test_create_user_embed_uses_png_format_of_user_avatar_as_thumbnail(sel
         """The embed thumbnail should be set to the user's avatar in `png` format."""
         ctx = helpers.MockContext()
 
-        user = helpers.MockMember(id=217)
+        user = helpers.MockMember(id=217, colour=0)
         user.avatar_url_as.return_value = "avatar url"
         embed = await self.cog.create_user_embed(ctx, user)