diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 3e7b002dc..6f7194d97 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -63,14 +63,17 @@ def _is_submodule(parent, child): return parent == child or child.startswith(parent + ".") -# barely spurious warning caused by our intentional shadowing +# Order of inheritance here matters. +# d.py autoshardedbot should be at the end +# all of our mixins should happen before, +# and must include a call to super().__init__ unless they do not provide an init class RedBase( - commands.GroupMixin, dpy_commands.bot.BotBase, RPCMixin -): # pylint: disable=no-member - """Mixin for the main bot class. - - This exists because `Red` inherits from `discord.AutoShardedClient`, which - is something other bot classes may not want to have as a parent class. + commands.GroupMixin, RPCMixin, dpy_commands.bot.AutoShardedBot +): # pylint: disable=no-member # barely spurious warning caused by shadowing + """ + The historical reasons for this mixin no longer apply + and only remains temporarily to not break people + relying on the publicly exposed bases existing. """ def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs): @@ -640,6 +643,9 @@ class RedBase( await self.rpc.initialize(self.rpc_port) async def start(self, *args, **kwargs): + """ + Overridden start which ensures cog load and other pre-connection tasks are handled + """ cli_flags = kwargs.pop("cli_flags") await self.pre_flight(cli_flags=cli_flags) return await super().start(*args, **kwargs) @@ -1237,12 +1243,6 @@ class RedBase( await asyncio.sleep(delay) await _delete_helper(message) - -class Red(RedBase, discord.AutoShardedClient): - """ - You're welcome Caleb. - """ - async def logout(self): """Logs out of Discord and closes all connections.""" await super().logout() @@ -1273,6 +1273,13 @@ class Red(RedBase, discord.AutoShardedClient): sys.exit(self._shutdown_mode) +# This can be removed, and the parent class renamed as a breaking change +class Red(RedBase): + """ + Our subclass of discord.ext.commands.AutoShardedBot + """ + + class ExitCodes(IntEnum): # This needs to be an int enum to be used # with sys.exit