Repository: python-discord/bot
Issue: Truncation of !roles Command Embed

Sentry Issue: [BOT-1Q](https://sentry.io/organizations/python-discord/issues/1531925673/?referrer=github_integration)

The `!roles` information command currently sticks role ID's & a corresponding mention into the `description` field of the embed:

https://github.com/python-discord/bot/blob/1ccc0f11fd4511d13c7cdf59070dca86465fe59f/bot/cogs/information.py#L31-L46

However, the `description` field has a character limit of `2048` characters and we now have more roles than can fit into this space so the command will raise an exception. We currently have `49` roles, the command generates around `45` characters per role, so math makes that `2205` characters.

Since this information is probably all useful to have, an alternative display mechanism will need to be utilized. Possible approaches include: pagination, filtering of roles to display, adjusting the information provided, etc.

Changed files:
bot/cogs/information.py, tests/bot/cogs/test_information.py

diff --git a/bot/cogs/information.py b/bot/cogs/information.py
index 49beca15..7921a493 100644
--- a/bot/cogs/information.py
+++ b/bot/cogs/information.py
@@ -13,6 +13,7 @@ from discord.utils import escape_markdown
 from bot import constants
 from bot.bot import Bot
 from bot.decorators import InChannelCheckFailure, in_channel, with_role
+from bot.pagination import LinePaginator
 from bot.utils.checks import cooldown_with_role_bypass, with_role_check
 from bot.utils.time import time_since
 
@@ -32,20 +33,18 @@ class Information(Cog):
         # Sort the roles alphabetically and remove the @everyone role
         roles = sorted(ctx.guild.roles[1:], key=lambda role: role.name)
 
-        # Build a string
-        role_string = ""
+        # Build a list
+        role_list = []
         for role in roles:
-            role_string += f"`{role.id}` - {role.mention}\\n"
+            role_list.append(f"`{role.id}` - {role.mention}")
 
         # Build an embed
         embed = Embed(
-            title="Role information",
-            colour=Colour.blurple(),
-            description=role_string
+            title=f"Role information (Total {len(roles)} role{'s' * (len(role_list) > 1)})",
+            colour=Colour.blurple()
         )
-        embed.set_footer(text=f"Total roles: {len(roles)}")
 
-        await ctx.send(embed=embed)
+        await LinePaginator.paginate(role_list, ctx, embed, empty=False)
 
     @with_role(*constants.MODERATION_ROLES)
     @command(name="role")
diff --git a/tests/bot/cogs/test_information.py b/tests/bot/cogs/test_information.py
index 5693d294..3c26374f 100644
--- a/tests/bot/cogs/test_information.py
+++ b/tests/bot/cogs/test_information.py
@@ -45,10 +45,9 @@ class InformationCogTests(unittest.TestCase):
         _, kwargs = self.ctx.send.call_args
         embed = kwargs.pop('embed')
 
-        self.assertEqual(embed.title, "Role information")
+        self.assertEqual(embed.title, "Role information (Total 1 role)")
         self.assertEqual(embed.colour, discord.Colour.blurple())
-        self.assertEqual(embed.description, f"`{self.moderator_role.id}` - {self.moderator_role.mention}\\n")
-        self.assertEqual(embed.footer.text, "Total roles: 1")
+        self.assertEqual(embed.description, f"\\n`{self.moderator_role.id}` - {self.moderator_role.mention}\\n")
 
     def test_role_info_command(self):
         """Tests the `role info` command."""