From 79e426f7ea68df718d178c059b5dcd9fdd636e22 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Sat, 17 May 2025 15:28:27 +0200 Subject: [PATCH] flags: Intents --- discord/flags.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/discord/flags.py b/discord/flags.py index 20f8c5470..7a841a216 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -40,12 +40,44 @@ from typing import ( Type, TypeVar, overload, + TypedDict, ) from .enums import UserFlags if TYPE_CHECKING: - from typing_extensions import Self + from typing_extensions import Self, Unpack, NotRequired + + class _IntentsFlagsKwargs(TypedDict): + guilds: NotRequired[bool] + members: NotRequired[bool] + moderation: NotRequired[bool] + bans: NotRequired[bool] + emojis: NotRequired[bool] + emojis_and_stickers: NotRequired[bool] + expressions: NotRequired[bool] + integrations: NotRequired[bool] + webhooks: NotRequired[bool] + invites: NotRequired[bool] + voice_states: NotRequired[bool] + presences: NotRequired[bool] + messages: NotRequired[bool] + guild_messages: NotRequired[bool] + dm_messages: NotRequired[bool] + reactions: NotRequired[bool] + guild_reactions: NotRequired[bool] + dm_reactions: NotRequired[bool] + typing: NotRequired[bool] + guild_typing: NotRequired[bool] + dm_typing: NotRequired[bool] + message_content: NotRequired[bool] + guild_scheduled_events: NotRequired[bool] + auto_moderation: NotRequired[bool] + auto_moderation_configuration: NotRequired[bool] + auto_moderation_execution: NotRequired[bool] + polls: NotRequired[bool] + guild_polls: NotRequired[bool] + dm_polls: NotRequired[bool] __all__ = ( @@ -754,12 +786,12 @@ class Intents(BaseFlags): __slots__ = () - def __init__(self, value: int = 0, **kwargs: bool) -> None: + def __init__(self, value: int = 0, **kwargs: Unpack[_IntentsFlagsKwargs]) -> None: self.value: int = value - for key, value in kwargs.items(): + for key, kwvalue in kwargs.items(): if key not in self.VALID_FLAGS: raise TypeError(f'{key!r} is not a valid flag name.') - setattr(self, key, value) + setattr(self, key, kwvalue) @classmethod def all(cls: Type[Intents]) -> Intents: