Skip to content

Commit

Permalink
refactor(client): add overloads for application command create and ed…
Browse files Browse the repository at this point in the history
…it methods (#1151)
  • Loading branch information
elenakrittik authored Jan 16, 2024
1 parent a5c1a8f commit d782f54
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/1151.feature.rst
Original file line number Diff line number Diff line change
@@ -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`.
92 changes: 91 additions & 1 deletion disnake/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit d782f54

Please sign in to comment.