Skip to content

Commit 13020e6

Browse files
committed
restructure BotBase.__init__
1 parent 53b5495 commit 13020e6

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

discord/bot.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
from __future__ import annotations # will probably need in future for type hinting
2626
import asyncio
27+
import collections
28+
import inspect
2729
import traceback
2830
from .app.errors import ApplicationCommandError, CheckFailure
2931

@@ -354,12 +356,29 @@ class be provided, it must be similar enough to
354356

355357
class BotBase(ApplicationCommandMixin, CogMixin):
356358
# TODO I think
357-
def __init__(self, *args, **kwargs):
359+
def __init__(self, description=None, *args, **options):
358360
# super(Client, self).__init__(*args, **kwargs)
359361
# I replaced ^ with v and it worked
360-
super().__init__(*args, **kwargs)
361-
self.debug_guild = kwargs.pop("debug_guild", None)
362-
self.debug_guilds = kwargs.pop("debug_guilds", None)
362+
super().__init__(*args, **options)
363+
self.extra_events = {} # TYPE: Dict[str, List[CoroFunc]]
364+
self.__cogs = {} # TYPE: Dict[str, Cog]
365+
self.__extensions = {} # TYPE: Dict[str, types.ModuleType]
366+
self._checks = [] # TYPE: List[Check]
367+
self._check_once = []
368+
self._before_invoke = None
369+
self._after_invoke = None
370+
self.description = inspect.cleandoc(description) if description else ''
371+
self.owner_id = options.get('owner_id')
372+
self.owner_ids = options.get('owner_ids', set())
373+
374+
self.debug_guild = options.pop("debug_guild", None) # TODO: remove or reimplement
375+
self.debug_guilds = options.pop("debug_guilds", None)
376+
377+
if self.owner_id and self.owner_ids:
378+
raise TypeError('Both owner_id and owner_ids are set.')
379+
380+
if self.owner_ids and not isinstance(self.owner_ids, collections.abc.Collection):
381+
raise TypeError(f'owner_ids must be a collection not {self.owner_ids.__class__!r}')
363382

364383
if self.debug_guild:
365384
if self.debug_guilds is None:

discord/ext/commands/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __repr__(self):
121121

122122
class BotBase(GroupMixin):
123123
def __init__(self, command_prefix=when_mentioned, help_command=_default, description=None, **options):
124+
# OVERRIDE 124: remove description param, 127-133, 135-137, 140-144
124125
super().__init__(**options)
125126
self.command_prefix = command_prefix
126127
self.extra_events: Dict[str, List[CoroFunc]] = {}

0 commit comments

Comments
 (0)