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`. 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: