Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(client): Add overloads for application command create and edit methods. #1151

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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