# Buggy code
def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs):
    self._shutdown_mode = ExitCodes.CRITICAL
    self._config = Config.get_core_conf(force_registration=False)
    self._co_owners = cli_flags.co_owner
    self.rpc_enabled = cli_flags.rpc
    self._last_exception = None
    self._config.register_global(
        token=None,
        prefix=[],
        packages=[],
        owner=None,
        whitelist=[],
        blacklist=[],
        locale="en-US",
        embeds=True,
        color=15158332,
        fuzzy=False,
        custom_info=None,
        help__page_char_limit=1000,
        help__max_pages_in_guild=2,
        help__use_menus=False,
        help__show_hidden=False,
        help__verify_checks=True,
        help__verify_exists=False,
        help__tagline="",
        invite_public=False,
        invite_perm=0,
        disabled_commands=[],
        disabled_command_msg="That command is disabled.",
        api_tokens={},
        extra_owner_destinations=[],
        owner_opt_out_list=[],
        schema_version=0,
    )

    self._config.register_guild(
        prefix=[],
        whitelist=[],
        blacklist=[],
        admin_role=[],
        mod_role=[],
        embeds=None,
        use_bot_color=False,
        fuzzy=False,
        disabled_commands=[],
        autoimmune_ids=[],
    )

    self._config.register_user(embeds=None)

    self._config.init_custom(CUSTOM_GROUPS, 2)
    self._config.register_custom(CUSTOM_GROUPS)

    async def prefix_manager(bot, message):
        if not cli_flags.prefix:
            global_prefix = await bot._config.prefix()
        else:
            global_prefix = cli_flags.prefix
        if message.guild is None:
            return global_prefix
        server_prefix = await bot._config.guild(message.guild).prefix()
        if cli_flags.mentionable:
            return (
                when_mentioned_or(*server_prefix)(bot, message)
                if server_prefix
                else when_mentioned_or(*global_prefix)(bot, message)
            )
        else:
            return server_prefix if server_prefix else global_prefix

    if "command_prefix" not in kwargs:
        kwargs["command_prefix"] = prefix_manager

    if cli_flags.owner and "owner_id" not in kwargs:
        kwargs["owner_id"] = cli_flags.owner

    if "owner_id" not in kwargs:
        loop = asyncio.get_event_loop()
        loop.run_until_complete(self._dict_abuse(kwargs))

    if "command_not_found" not in kwargs:
        kwargs["command_not_found"] = "Command {} not found.\n{}"

    self._counter = Counter()
    self._uptime = None
    self._checked_time_accuracy = None
    self._color = discord.Embed.Empty  # This is needed or color ends up 0x000000

    self.main_dir = bot_dir

    self.cog_mgr = CogManager()

    super().__init__(*args, help_command=None, **kwargs)
    # Do not manually use the help formatter attribute here, see `send_help_for`,
    # for a documented API. The internals of this object are still subject to change.
    self._help_formatter = commands.help.RedHelpFormatter()
    self.add_command(commands.help.red_help)

    self._permissions_hooks: List[commands.CheckPredicate] = []


# 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
def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs):
    self._shutdown_mode = ExitCodes.CRITICAL
    self._config = Config.get_core_conf(force_registration=False)
    self._co_owners = cli_flags.co_owner
    self.rpc_enabled = cli_flags.rpc
    self._last_exception = None
    self._config.register_global(
        token=None,
        prefix=[],
        packages=[],
        owner=None,
        whitelist=[],
        blacklist=[],
        locale="en-US",
        embeds=True,
        color=15158332,
        fuzzy=False,
        custom_info=None,
        help__page_char_limit=1000,
        help__max_pages_in_guild=2,
        help__use_menus=False,
        help__show_hidden=False,
        help__verify_checks=True,
        help__verify_exists=False,
        help__tagline="",
        invite_public=False,
        invite_perm=0,
        disabled_commands=[],
        disabled_command_msg="That command is disabled.",
        extra_owner_destinations=[],
        owner_opt_out_list=[],
        schema_version=0,
    )

    self._config.register_guild(
        prefix=[],
        whitelist=[],
        blacklist=[],
        admin_role=[],
        mod_role=[],
        embeds=None,
        use_bot_color=False,
        fuzzy=False,
        disabled_commands=[],
        autoimmune_ids=[],
    )

    self._config.register_user(embeds=None)

    self._config.init_custom(CUSTOM_GROUPS, 2)
    self._config.register_custom(CUSTOM_GROUPS)

    self._config.init_custom(SHARED_API_TOKENS, 2)
    self._config.register_custom(SHARED_API_TOKENS)

    async def prefix_manager(bot, message):
        if not cli_flags.prefix:
            global_prefix = await bot._config.prefix()
        else:
            global_prefix = cli_flags.prefix
        if message.guild is None:
            return global_prefix
        server_prefix = await bot._config.guild(message.guild).prefix()
        if cli_flags.mentionable:
            return (
                when_mentioned_or(*server_prefix)(bot, message)
                if server_prefix
                else when_mentioned_or(*global_prefix)(bot, message)
            )
        else:
            return server_prefix if server_prefix else global_prefix

    if "command_prefix" not in kwargs:
        kwargs["command_prefix"] = prefix_manager

    if cli_flags.owner and "owner_id" not in kwargs:
        kwargs["owner_id"] = cli_flags.owner

    if "owner_id" not in kwargs:
        loop = asyncio.get_event_loop()
        loop.run_until_complete(self._dict_abuse(kwargs))

    if "command_not_found" not in kwargs:
        kwargs["command_not_found"] = "Command {} not found.\n{}"

    self._uptime = None
    self._checked_time_accuracy = None
    self._color = discord.Embed.Empty  # This is needed or color ends up 0x000000

    self._main_dir = bot_dir
    self._cog_mgr = CogManager()

    super().__init__(*args, help_command=None, **kwargs)
    # Do not manually use the help formatter attribute here, see `send_help_for`,
    # for a documented API. The internals of this object are still subject to change.
    self._help_formatter = commands.help.RedHelpFormatter()
    self.add_command(commands.help.red_help)

    self._permissions_hooks: List[commands.CheckPredicate] = []