Browse Source

Fix typing of various AppCommand decorators

pull/9823/head
Michael H 11 months ago
committed by GitHub
parent
commit
a1206dfde8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 46
      discord/app_commands/commands.py

46
discord/app_commands/commands.py

@ -2523,6 +2523,16 @@ def guild_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
return inner(func) return inner(func)
@overload
def private_channel_only(func: None = ...) -> Callable[[T], T]:
...
@overload
def private_channel_only(func: T) -> T:
...
def private_channel_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]: def private_channel_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
"""A decorator that indicates this command can only be used in the context of DMs and group DMs. """A decorator that indicates this command can only be used in the context of DMs and group DMs.
@ -2565,6 +2575,16 @@ def private_channel_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]
return inner(func) return inner(func)
@overload
def dm_only(func: None = ...) -> Callable[[T], T]:
...
@overload
def dm_only(func: T) -> T:
...
def dm_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]: def dm_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
"""A decorator that indicates this command can only be used in the context of bot DMs. """A decorator that indicates this command can only be used in the context of bot DMs.
@ -2606,9 +2626,7 @@ def dm_only(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
return inner(func) return inner(func)
def allowed_contexts( def allowed_contexts(guilds: bool = MISSING, dms: bool = MISSING, private_channels: bool = MISSING) -> Callable[[T], T]:
guilds: bool = MISSING, dms: bool = MISSING, private_channels: bool = MISSING
) -> Union[T, Callable[[T], T]]:
"""A decorator that indicates this command can only be used in certain contexts. """A decorator that indicates this command can only be used in certain contexts.
Valid contexts are guilds, DMs and private channels. Valid contexts are guilds, DMs and private channels.
@ -2650,6 +2668,16 @@ def allowed_contexts(
return inner return inner
@overload
def guild_install(func: None = ...) -> Callable[[T], T]:
...
@overload
def guild_install(func: T) -> T:
...
def guild_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]: def guild_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
"""A decorator that indicates this command should be installed in guilds. """A decorator that indicates this command should be installed in guilds.
@ -2688,6 +2716,16 @@ def guild_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
return inner(func) return inner(func)
@overload
def user_install(func: None = ...) -> Callable[[T], T]:
...
@overload
def user_install(func: T) -> T:
...
def user_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]: def user_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
"""A decorator that indicates this command should be installed for users. """A decorator that indicates this command should be installed for users.
@ -2729,7 +2767,7 @@ def user_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:
def allowed_installs( def allowed_installs(
guilds: bool = MISSING, guilds: bool = MISSING,
users: bool = MISSING, users: bool = MISSING,
) -> Union[T, Callable[[T], T]]: ) -> Callable[[T], T]:
"""A decorator that indicates this command should be installed in certain contexts. """A decorator that indicates this command should be installed in certain contexts.
Valid contexts are guilds and users. Valid contexts are guilds and users.

Loading…
Cancel
Save