diff options
| author | 2020-07-22 23:51:08 -0700 | |
|---|---|---|
| committer | 2020-07-22 23:51:08 -0700 | |
| commit | 0ee8a47d9796e88f7185d9084bad2cbf981c28ac (patch) | |
| tree | 69d4b1814d55f9f25dc9f4b196ea2b2c2524cbb3 | |
| parent | Merge pull request #1063 from python-discord/bug/util/jams-multi-categories (diff) | |
| parent | Merge branch 'master' into bug/util/897/truncate-charinfo (diff) | |
Merge pull request #1062 from python-discord/bug/util/897/truncate-charinfo
Truncate charinfo results
| -rw-r--r-- | bot/cogs/utils.py | 36 | 
1 files changed, 15 insertions, 21 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index 697bf60ce..017f3419e 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -12,6 +12,8 @@ from discord.ext.commands import BadArgument, Cog, Context, command  from bot.bot import Bot  from bot.constants import Channels, MODERATION_ROLES, STAFF_ROLES  from bot.decorators import in_whitelist, with_role +from bot.pagination import LinePaginator +from bot.utils import messages  log = logging.getLogger(__name__) @@ -117,25 +119,18 @@ class Utils(Cog):      @command()      @in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES)      async def charinfo(self, ctx: Context, *, characters: str) -> None: -        """Shows you information on up to 25 unicode characters.""" +        """Shows you information on up to 50 unicode characters."""          match = re.match(r"<(a?):(\w+):(\d+)>", characters)          if match: -            embed = Embed( -                title="Non-Character Detected", -                description=( -                    "Only unicode characters can be processed, but a custom Discord emoji " -                    "was found. Please remove it and try again." -                ) +            return await messages.send_denial( +                ctx, +                "**Non-Character Detected**\n" +                "Only unicode characters can be processed, but a custom Discord emoji " +                "was found. Please remove it and try again."              ) -            embed.colour = Colour.red() -            await ctx.send(embed=embed) -            return -        if len(characters) > 25: -            embed = Embed(title=f"Too many characters ({len(characters)}/25)") -            embed.colour = Colour.red() -            await ctx.send(embed=embed) -            return +        if len(characters) > 50: +            return await messages.send_denial(ctx, f"Too many characters ({len(characters)}/50)")          def get_info(char: str) -> Tuple[str, str]:              digit = f"{ord(char):x}" @@ -148,15 +143,14 @@ class Utils(Cog):              info = f"`{u_code.ljust(10)}`: {name} - {utils.escape_markdown(char)}"              return info, u_code -        charlist, rawlist = zip(*(get_info(c) for c in characters)) - -        embed = Embed(description="\n".join(charlist)) -        embed.set_author(name="Character Info") +        char_list, raw_list = zip(*(get_info(c) for c in characters)) +        embed = Embed().set_author(name="Character Info")          if len(characters) > 1: -            embed.add_field(name='Raw', value=f"`{''.join(rawlist)}`", inline=False) +            # Maximum length possible is 502 out of 1024, so there's no need to truncate. +            embed.add_field(name='Full Raw Text', value=f"`{''.join(raw_list)}`", inline=False) -        await ctx.send(embed=embed) +        await LinePaginator.paginate(char_list, ctx, embed, max_lines=10, max_size=2000, empty=False)      @command()      async def zen(self, ctx: Context, *, search_value: Union[int, str, None] = None) -> None:  |