Browse Source

fix: intents should actually be required

pull/10189/head
Soheab_ 2 weeks ago
parent
commit
b4a10c50fb
  1. 5
      discord/client.py
  2. 3
      discord/ext/commands/bot.py

5
discord/client.py

@ -124,7 +124,6 @@ if TYPE_CHECKING:
from .flags import MemberCacheFlags from .flags import MemberCacheFlags
class _ClientOptions(TypedDict, total=False): class _ClientOptions(TypedDict, total=False):
intents: Required[Intents]
max_messages: NotRequired[Optional[int]] max_messages: NotRequired[Optional[int]]
proxy: NotRequired[Optional[str]] proxy: NotRequired[Optional[str]]
proxy_auth: NotRequired[Optional[aiohttp.BasicAuth]] proxy_auth: NotRequired[Optional[aiohttp.BasicAuth]]
@ -295,7 +294,7 @@ class Client:
The websocket gateway the client is currently connected to. Could be ``None``. The websocket gateway the client is currently connected to. Could be ``None``.
""" """
def __init__(self, **options: Unpack[_ClientOptions]) -> None: def __init__(self, *, intents: Intents, **options: Unpack[_ClientOptions]) -> None:
self.loop: asyncio.AbstractEventLoop = _loop self.loop: asyncio.AbstractEventLoop = _loop
# self.ws is set in the connect method # self.ws is set in the connect method
self.ws: DiscordWebSocket = None # type: ignore self.ws: DiscordWebSocket = None # type: ignore
@ -328,7 +327,7 @@ class Client:
} }
self._enable_debug_events: bool = options.pop('enable_debug_events', False) self._enable_debug_events: bool = options.pop('enable_debug_events', False)
self._connection: ConnectionState[Self] = self._get_state(**options) self._connection: ConnectionState[Self] = self._get_state(intents=intents, **options)
self._connection.shard_count = self.shard_count self._connection.shard_count = self.shard_count
self._closing_task: Optional[asyncio.Task[None]] = None self._closing_task: Optional[asyncio.Task[None]] = None
self._ready: asyncio.Event = MISSING self._ready: asyncio.Event = MISSING

3
discord/ext/commands/bot.py

@ -175,9 +175,10 @@ class BotBase(GroupMixin[None]):
description: Optional[str] = None, description: Optional[str] = None,
allowed_contexts: app_commands.AppCommandContext = MISSING, allowed_contexts: app_commands.AppCommandContext = MISSING,
allowed_installs: app_commands.AppInstallationType = MISSING, allowed_installs: app_commands.AppInstallationType = MISSING,
intents: discord.Intents,
**options: Unpack[_BotOptions], **options: Unpack[_BotOptions],
) -> None: ) -> None:
super().__init__(**options) super().__init__(intents=intents, **options)
self.command_prefix: PrefixType[BotT] = command_prefix # type: ignore self.command_prefix: PrefixType[BotT] = command_prefix # type: ignore
self.extra_events: Dict[str, List[CoroFunc]] = {} self.extra_events: Dict[str, List[CoroFunc]] = {}
# Self doesn't have the ClientT bound, but since this is a mixin it technically does # Self doesn't have the ClientT bound, but since this is a mixin it technically does

Loading…
Cancel
Save