From 52e302bcc183828d14e6e920da695fa8e2b63ea8 Mon Sep 17 00:00:00 2001 From: elenakrittik Date: Sun, 14 Jan 2024 17:40:23 +0300 Subject: [PATCH 1/2] Go! --- disnake/client.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/disnake/client.py b/disnake/client.py index a5b0d54775..0fed3eb8e4 100644 --- a/disnake/client.py +++ b/disnake/client.py @@ -85,7 +85,7 @@ from typing_extensions import NotRequired from .abc import GuildChannel, PrivateChannel, Snowflake, SnowflakeTime - from .app_commands import APIApplicationCommand + from .app_commands import APIApplicationCommand, MessageCommand, SlashCommand, UserCommand from .asset import AssetBytes from .channel import DMChannel from .member import Member @@ -2660,6 +2660,24 @@ async def fetch_global_command(self, command_id: int) -> APIApplicationCommand: """ return await self._connection.fetch_global_command(command_id) + @overload + async def create_global_command(self, application_command: SlashCommand) -> APISlashCommand: + ... + + @overload + async def create_global_command(self, application_command: UserCommand) -> APIUserCommand: + ... + + @overload + async def create_global_command(self, application_command: MessageCommand) -> APIMessageCommand: + ... + + @overload + async def create_global_command( + self, application_command: ApplicationCommand + ) -> APIApplicationCommand: + ... + async def create_global_command( self, application_command: ApplicationCommand ) -> APIApplicationCommand: @@ -2682,6 +2700,30 @@ async def create_global_command( application_command.localize(self.i18n) return await self._connection.create_global_command(application_command) + @overload + async def edit_global_command( + self, command_id: int, new_command: SlashCommand + ) -> APISlashCommand: + ... + + @overload + async def edit_global_command( + self, command_id: int, new_command: UserCommand + ) -> APIUserCommand: + ... + + @overload + async def edit_global_command( + self, command_id: int, new_command: MessageCommand + ) -> APIMessageCommand: + ... + + @overload + async def edit_global_command( + self, command_id: int, new_command: ApplicationCommand + ) -> APIApplicationCommand: + ... + async def edit_global_command( self, command_id: int, new_command: ApplicationCommand ) -> APIApplicationCommand: @@ -2796,6 +2838,30 @@ async def fetch_guild_command(self, guild_id: int, command_id: int) -> APIApplic """ return await self._connection.fetch_guild_command(guild_id, command_id) + @overload + async def create_guild_command( + self, guild_id: int, application_command: SlashCommand + ) -> APISlashCommand: + ... + + @overload + async def create_guild_command( + self, guild_id: int, application_command: UserCommand + ) -> APIUserCommand: + ... + + @overload + async def create_guild_command( + self, guild_id: int, application_command: MessageCommand + ) -> APIMessageCommand: + ... + + @overload + async def create_guild_command( + self, guild_id: int, application_command: ApplicationCommand + ) -> APIApplicationCommand: + ... + async def create_guild_command( self, guild_id: int, application_command: ApplicationCommand ) -> APIApplicationCommand: @@ -2820,6 +2886,30 @@ async def create_guild_command( application_command.localize(self.i18n) return await self._connection.create_guild_command(guild_id, application_command) + @overload + async def edit_guild_command( + self, guild_id: int, command_id: int, new_command: SlashCommand + ) -> APISlashCommand: + ... + + @overload + async def edit_guild_command( + self, guild_id: int, command_id: int, new_command: UserCommand + ) -> APIUserCommand: + ... + + @overload + async def edit_guild_command( + self, guild_id: int, command_id: int, new_command: MessageCommand + ) -> APIMessageCommand: + ... + + @overload + async def edit_guild_command( + self, guild_id: int, command_id: int, new_command: ApplicationCommand + ) -> APIApplicationCommand: + ... + async def edit_guild_command( self, guild_id: int, command_id: int, new_command: ApplicationCommand ) -> APIApplicationCommand: From c2129896ad731ca7feccb6049b31988cabda714f Mon Sep 17 00:00:00 2001 From: elenakrittik Date: Sun, 14 Jan 2024 17:51:56 +0300 Subject: [PATCH 2/2] Go! --- changelog/1151.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/1151.feature.rst diff --git a/changelog/1151.feature.rst b/changelog/1151.feature.rst new file mode 100644 index 0000000000..95c37aeca8 --- /dev/null +++ b/changelog/1151.feature.rst @@ -0,0 +1 @@ +Make typing more precise for :meth:`Client.create_global_command`, :meth:`Client.edit_global_command`, :meth:`Client.create_guild_command` and :meth:`Client.edit_guild_command`.