From 4032648dcc0284f5ad59696f2590bb766534eac3 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 5 Apr 2026 21:52:43 +0200 Subject: [PATCH] Simplify bot class (Red) __init__ arguments, remove unused (#6714) --- docs/framework_bot.rst | 2 +- redbot/__main__.py | 4 ++-- redbot/core/bot.py | 17 ++++++++++++++--- redbot/pytest/core.py | 4 +--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/framework_bot.rst b/docs/framework_bot.rst index 27627ae18..4092fef54 100644 --- a/docs/framework_bot.rst +++ b/docs/framework_bot.rst @@ -9,7 +9,7 @@ Bot Red ^^^ -.. autoclass:: Red +.. autoclass:: Red() :members: :exclude-members: get_context, get_embed_color diff --git a/redbot/__main__.py b/redbot/__main__.py index 42f9a09b2..f741af28c 100644 --- a/redbot/__main__.py +++ b/redbot/__main__.py @@ -281,7 +281,7 @@ def early_exit_runner( return data_manager.load_basic_configuration(cli_flags.instance_name) - red = Red(cli_flags=cli_flags, description="Red V3", dm_help=None) + red = Red(cli_flags=cli_flags) driver_cls = _drivers.get_driver_class() loop.run_until_complete(driver_cls.initialize(**data_manager.storage_details())) loop.run_until_complete(func(red, cli_flags)) @@ -494,7 +494,7 @@ def main(): data_manager.load_basic_configuration(cli_flags.instance_name) - red = Red(cli_flags=cli_flags, description="Red V3", dm_help=None) + red = Red(cli_flags=cli_flags) if os.name != "nt": # None of this works on windows. diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 3b1b4eef1..bbcf4595d 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -1,4 +1,5 @@ from __future__ import annotations +import argparse import asyncio import inspect import logging @@ -80,6 +81,8 @@ CUSTOM_GROUPS = "CUSTOM_GROUPS" COMMAND_SCOPE = "COMMAND" SHARED_API_TOKENS = "SHARED_API_TOKENS" +_DEFAULT_DESCRIPTION = "Red V3" + log = logging.getLogger("red") __all__ = ("Red",) @@ -112,7 +115,9 @@ class Red( ): # pylint: disable=no-member # barely spurious warning caused by shadowing """Our subclass of discord.ext.commands.AutoShardedBot""" - def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs): + def __init__( + self, *args: Any, cli_flags: argparse.Namespace, bot_dir: Path = Path.cwd(), **kwargs: Any + ) -> None: self._shutdown_mode = ExitCodes.CRITICAL self._cli_flags = cli_flags self._config = Config.get_core_conf(force_registration=False) @@ -143,7 +148,7 @@ class Red( help__tagline="", help__use_tick=False, help__react_timeout=30, - description="Red V3", + description=_DEFAULT_DESCRIPTION, invite_public=False, invite_perm=0, invite_commands_scope=False, @@ -250,7 +255,13 @@ class Red( self._main_dir = bot_dir self._cog_mgr = CogManager() self._use_team_features = cli_flags.use_team_features - super().__init__(*args, help_command=None, tree_cls=RedTree, **kwargs) + super().__init__( + *args, + description=kwargs.pop("description", _DEFAULT_DESCRIPTION), + help_command=None, + tree_cls=RedTree, + **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() diff --git a/redbot/pytest/core.py b/redbot/pytest/core.py index 57450f8e4..5795052dd 100644 --- a/redbot/pytest/core.py +++ b/redbot/pytest/core.py @@ -172,11 +172,9 @@ def red(config_fr): cli_flags = parse_cli_flags(["ignore_me"]) - description = "Red v3 - Alpha" - Config.get_core_conf = lambda *args, **kwargs: config_fr - red = Red(cli_flags=cli_flags, description=description, dm_help=None, owner_ids=set()) + red = Red(cli_flags=cli_flags) yield red