Skip to content

Commit c1a57fa

Browse files
authored
fix: update typed dicts for commands (Pycord-Development#2274)
1 parent 98c4e19 commit c1a57fa

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

discord/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ async def on_connect():
781781
lambda cmd: cmd.name == i["name"]
782782
and cmd.type == i.get("type")
783783
and cmd.guild_ids is not None
784-
# TODO: fix this type error (guild_id is not defined in ApplicationCommand Typed Dict)
785-
and int(i["guild_id"]) in cmd.guild_ids, # type: ignore
784+
and (guild_id := i.get("guild_id"))
785+
and guild_id in cmd.guild_ids,
786786
self.pending_application_commands,
787787
)
788788
if not cmd:

discord/types/interactions.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,45 @@
4747

4848

4949
class ApplicationCommand(TypedDict):
50-
options: NotRequired[list[ApplicationCommandOption]]
51-
type: NotRequired[ApplicationCommandType]
52-
name_localized: NotRequired[str]
53-
name_localizations: NotRequired[dict[str, str]]
54-
description_localized: NotRequired[str]
55-
description_localizations: NotRequired[dict[str, str]]
5650
id: Snowflake
51+
type: NotRequired[ApplicationCommandType]
5752
application_id: Snowflake
53+
guild_id: NotRequired[Snowflake]
5854
name: str
55+
name_localizations: NotRequired[dict[str, str] | None]
5956
description: str
57+
description_localizations: NotRequired[dict[str, str] | None]
58+
options: NotRequired[list[ApplicationCommandOption]]
59+
default_member_permissions: str | None
60+
dm_permission: NotRequired[bool]
61+
default_permission: NotRequired[bool | None]
62+
nsfw: NotRequired[bool]
63+
version: Snowflake
6064

6165

6266
ApplicationCommandOptionType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
6367

6468

6569
class ApplicationCommandOption(TypedDict):
66-
choices: NotRequired[list[ApplicationCommandOptionChoice]]
67-
options: NotRequired[list[ApplicationCommandOption]]
68-
name_localizations: NotRequired[dict[str, str]]
69-
description_localizations: NotRequired[dict[str, str]]
7070
type: ApplicationCommandOptionType
7171
name: str
72+
name_localizations: NotRequired[dict[str, str] | None]
7273
description: str
74+
description_localizations: NotRequired[dict[str, str] | None]
7375
required: bool
76+
options: NotRequired[list[ApplicationCommandOption]]
77+
choices: NotRequired[list[ApplicationCommandOptionChoice]]
78+
channel_types: NotRequired[list[ChannelType]]
79+
min_value: NotRequired[int | float]
80+
max_value: NotRequired[int | float]
81+
min_length: NotRequired[int]
82+
max_length: NotRequired[int]
83+
autocomplete: NotRequired[bool]
7484

7585

7686
class ApplicationCommandOptionChoice(TypedDict):
77-
name_localizations: NotRequired[dict[str, str]]
7887
name: str
88+
name_localizations: NotRequired[dict[str, str] | None]
7989
value: str | int
8090

8191

0 commit comments

Comments
 (0)