Skip to content

Commit

Permalink
restructure BotBase.__init__
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDotCom committed Sep 8, 2021
1 parent 53b5495 commit 13020e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions discord/ext/commands/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = {}
Expand Down

0 comments on commit 13020e6

Please sign in to comment.