Repository: Pycord-Development/pycord

Issue:
fix this type error (guild_id is not defined in ApplicationCommand Typed Dict)


Line: 764
https://github.com/Pycord-Development/pycord/blob/6ab3292b8984cce19e00afaead0c080acf9ec687//discord/bot.py#L761-L771


Discussion:

Resolving patch:
diff --git a/discord/bot.py b/discord/bot.py
--- a/discord/bot.py
+++ b/discord/bot.py
@@ -781,8 +781,8 @@ async def on_connect():
                         lambda cmd: cmd.name == i["name"]
                         and cmd.type == i.get("type")
                         and cmd.guild_ids is not None
-                        # TODO: fix this type error (guild_id is not defined in ApplicationCommand Typed Dict)
-                        and int(i["guild_id"]) in cmd.guild_ids,  # type: ignore
+                        and (guild_id := i.get("guild_id"))
+                        and guild_id in cmd.guild_ids,
                         self.pending_application_commands,
                     )
                     if not cmd:
diff --git a/discord/types/interactions.py b/discord/types/interactions.py
--- a/discord/types/interactions.py
+++ b/discord/types/interactions.py
@@ -47,35 +47,45 @@
 
 
 class ApplicationCommand(TypedDict):
-    options: NotRequired[list[ApplicationCommandOption]]
-    type: NotRequired[ApplicationCommandType]
-    name_localized: NotRequired[str]
-    name_localizations: NotRequired[dict[str, str]]
-    description_localized: NotRequired[str]
-    description_localizations: NotRequired[dict[str, str]]
     id: Snowflake
+    type: NotRequired[ApplicationCommandType]
     application_id: Snowflake
+    guild_id: NotRequired[Snowflake]
     name: str
+    name_localizations: NotRequired[dict[str, str] | None]
     description: str
+    description_localizations: NotRequired[dict[str, str] | None]
+    options: NotRequired[list[ApplicationCommandOption]]
+    default_member_permissions: str | None
+    dm_permission: NotRequired[bool]
+    default_permission: NotRequired[bool | None]
+    nsfw: NotRequired[bool]
+    version: Snowflake
 
 
 ApplicationCommandOptionType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
 
 
 class ApplicationCommandOption(TypedDict):
-    choices: NotRequired[list[ApplicationCommandOptionChoice]]
-    options: NotRequired[list[ApplicationCommandOption]]
-    name_localizations: NotRequired[dict[str, str]]
-    description_localizations: NotRequired[dict[str, str]]
     type: ApplicationCommandOptionType
     name: str
+    name_localizations: NotRequired[dict[str, str] | None]
     description: str
+    description_localizations: NotRequired[dict[str, str] | None]
     required: bool
+    options: NotRequired[list[ApplicationCommandOption]]
+    choices: NotRequired[list[ApplicationCommandOptionChoice]]
+    channel_types: NotRequired[list[ChannelType]]
+    min_value: NotRequired[int | float]
+    max_value: NotRequired[int | float]
+    min_length: NotRequired[int]
+    max_length: NotRequired[int]
+    autocomplete: NotRequired[bool]
 
 
 class ApplicationCommandOptionChoice(TypedDict):
-    name_localizations: NotRequired[dict[str, str]]
     name: str
+    name_localizations: NotRequired[dict[str, str] | None]
     value: str | int
 
 


Test patch: