Require passing intents to Client and its subclasses

This commit is contained in:
Rapptz
2022-04-05 22:12:55 -04:00
parent 7770972041
commit 76cc2c2272
4 changed files with 34 additions and 6 deletions

View File

@@ -140,9 +140,11 @@ class Client:
intents: :class:`Intents`
The intents that you want to enable for the session. This is a way of
disabling and enabling certain gateway events from triggering and being sent.
If not given, defaults to a regularly constructed :class:`Intents` class.
.. versionadded:: 1.5
.. versionchanged:: 2.0
Parameter is now required.
member_cache_flags: :class:`MemberCacheFlags`
Allows for finer control over how the library caches members.
If not given, defaults to cache as much as possible with the
@@ -203,7 +205,7 @@ class Client:
The websocket gateway the client is currently connected to. Could be ``None``.
"""
def __init__(self, **options: Any) -> None:
def __init__(self, *, intents: Intents, **options: Any) -> None:
self.loop: asyncio.AbstractEventLoop = _loop
# self.ws is set in the connect method
self.ws: DiscordWebSocket = None # type: ignore
@@ -232,7 +234,7 @@ class Client:
}
self._enable_debug_events: bool = options.pop('enable_debug_events', False)
self._connection: ConnectionState = self._get_state(**options)
self._connection: ConnectionState = self._get_state(intents=intents, **options)
self._connection.shard_count = self.shard_count
self._closed: bool = False
self._ready: asyncio.Event = MISSING