From 13020e6630d1f105f14bdd57418e8fb536b0a015 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 8 Sep 2021 14:02:02 -0500 Subject: [PATCH] restructure BotBase.__init__ --- discord/bot.py | 27 +++++++++++++++++++++++---- discord/ext/commands/bot.py | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/discord/bot.py b/discord/bot.py index e41fbaa895..732d0b2dc2 100644 --- a/discord/bot.py +++ b/discord/bot.py @@ -24,6 +24,8 @@ from __future__ import annotations # will probably need in future for type hinting import asyncio +import collections +import inspect import traceback from .app.errors import ApplicationCommandError, CheckFailure @@ -354,12 +356,29 @@ class be provided, it must be similar enough to class BotBase(ApplicationCommandMixin, CogMixin): # TODO I think - def __init__(self, *args, **kwargs): + def __init__(self, description=None, *args, **options): # super(Client, self).__init__(*args, **kwargs) # I replaced ^ with v and it worked - super().__init__(*args, **kwargs) - self.debug_guild = kwargs.pop("debug_guild", None) - self.debug_guilds = kwargs.pop("debug_guilds", None) + super().__init__(*args, **options) + self.extra_events = {} # TYPE: Dict[str, List[CoroFunc]] + self.__cogs = {} # TYPE: Dict[str, Cog] + self.__extensions = {} # TYPE: Dict[str, types.ModuleType] + self._checks = [] # TYPE: List[Check] + self._check_once = [] + self._before_invoke = None + self._after_invoke = None + self.description = inspect.cleandoc(description) if description else '' + self.owner_id = options.get('owner_id') + self.owner_ids = options.get('owner_ids', set()) + + self.debug_guild = options.pop("debug_guild", None) # TODO: remove or reimplement + self.debug_guilds = options.pop("debug_guilds", None) + + if self.owner_id and self.owner_ids: + raise TypeError('Both owner_id and owner_ids are set.') + + if self.owner_ids and not isinstance(self.owner_ids, collections.abc.Collection): + raise TypeError(f'owner_ids must be a collection not {self.owner_ids.__class__!r}') if self.debug_guild: if self.debug_guilds is None: diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index fed3a56286..552433719c 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -121,6 +121,7 @@ def __repr__(self): class BotBase(GroupMixin): def __init__(self, command_prefix=when_mentioned, help_command=_default, description=None, **options): + # OVERRIDE 124: remove description param, 127-133, 135-137, 140-144 super().__init__(**options) self.command_prefix = command_prefix self.extra_events: Dict[str, List[CoroFunc]] = {}