# Buggy code
async def cogs(self, ctx: commands.Context):
    """
    Lists all loaded and available cogs.
    """
    loaded = set(ctx.bot.extensions.keys())

    all_cogs = set(await ctx.bot.cog_mgr.available_modules())

    unloaded = all_cogs - loaded

    loaded = sorted(list(loaded), key=str.lower)
    unloaded = sorted(list(unloaded), key=str.lower)

    if await ctx.embed_requested():
        loaded = _("**{} loaded:**\n").format(len(loaded)) + ", ".join(loaded)
        unloaded = _("**{} unloaded:**\n").format(len(unloaded)) + ", ".join(unloaded)

        for page in pagify(loaded, delims=[", ", "\n"], page_length=1800):
            e = discord.Embed(description=page, colour=discord.Colour.dark_green())
            await ctx.send(embed=e)

        for page in pagify(unloaded, delims=[", ", "\n"], page_length=1800):
            e = discord.Embed(description=page, colour=discord.Colour.dark_red())
            await ctx.send(embed=e)
    else:
        loaded_count = _("**{} loaded:**\n").format(len(loaded))
        loaded = ", ".join(loaded)
        unloaded_count = _("**{} unloaded:**\n").format(len(unloaded))
        unloaded = ", ".join(unloaded)
        loaded_count_sent = False
        unloaded_count_sent = False
        for page in pagify(loaded, delims=[", ", "\n"], page_length=1800):
            if page.startswith(", "):
                page = page[2:]
            if not loaded_count_sent:
                await ctx.send(loaded_count + box(page, lang="css"))
                loaded_count_sent = True
            else:
                await ctx.send(box(page, lang="css"))

        for page in pagify(unloaded, delims=[", ", "\n"], page_length=1800):
            if page.startswith(", "):
                page = page[2:]
            if not unloaded_count_sent:
                await ctx.send(unloaded_count + box(page, lang="ldif"))
                unloaded_count_sent = True
            else:
                await ctx.send(box(page, lang="ldif"))


# Traceback (AttributeError)
Traceback (most recent call last):
File "c:\python37\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "c:\python37\lib\site-packages\redbot\core\core_commands.py", line 334, in uptime
since = ctx.bot.uptime.strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'Red' object has no attribute 'uptime'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c:\python37\lib\site-packages\discord\ext\commands\bot.py", line 863, in invoke
await ctx.command.invoke(ctx)
File "c:\python37\lib\site-packages\discord\ext\commands\core.py", line 728, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "c:\python37\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Red' object has no attribute 'uptime'

# Fixed code
async def cogs(self, ctx: commands.Context):
    """
    Lists all loaded and available cogs.
    """
    loaded = set(ctx.bot.extensions.keys())

    all_cogs = set(await ctx.bot._cog_mgr.available_modules())

    unloaded = all_cogs - loaded

    loaded = sorted(list(loaded), key=str.lower)
    unloaded = sorted(list(unloaded), key=str.lower)

    if await ctx.embed_requested():
        loaded = _("**{} loaded:**\n").format(len(loaded)) + ", ".join(loaded)
        unloaded = _("**{} unloaded:**\n").format(len(unloaded)) + ", ".join(unloaded)

        for page in pagify(loaded, delims=[", ", "\n"], page_length=1800):
            e = discord.Embed(description=page, colour=discord.Colour.dark_green())
            await ctx.send(embed=e)

        for page in pagify(unloaded, delims=[", ", "\n"], page_length=1800):
            e = discord.Embed(description=page, colour=discord.Colour.dark_red())
            await ctx.send(embed=e)
    else:
        loaded_count = _("**{} loaded:**\n").format(len(loaded))
        loaded = ", ".join(loaded)
        unloaded_count = _("**{} unloaded:**\n").format(len(unloaded))
        unloaded = ", ".join(unloaded)
        loaded_count_sent = False
        unloaded_count_sent = False
        for page in pagify(loaded, delims=[", ", "\n"], page_length=1800):
            if page.startswith(", "):
                page = page[2:]
            if not loaded_count_sent:
                await ctx.send(loaded_count + box(page, lang="css"))
                loaded_count_sent = True
            else:
                await ctx.send(box(page, lang="css"))

        for page in pagify(unloaded, delims=[", ", "\n"], page_length=1800):
            if page.startswith(", "):
                page = page[2:]
            if not unloaded_count_sent:
                await ctx.send(unloaded_count + box(page, lang="ldif"))
                unloaded_count_sent = True
            else:
                await ctx.send(box(page, lang="ldif"))