Skip to content

Commit

Permalink
Fix typing of various AppCommand decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshardmind committed May 9, 2024
1 parent 0bb6967 commit a1206df
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions discord/app_commands/commands.py
Expand Up @@ -2523,6 +2523,16 @@ def inner(f: T) -> T:
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]]:
"""A decorator that indicates this command can only be used in the context of DMs and group DMs.
Expand Down Expand Up @@ -2565,6 +2575,16 @@ def inner(f: T) -> T:
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]]:
"""A decorator that indicates this command can only be used in the context of bot DMs.
Expand Down Expand Up @@ -2606,9 +2626,7 @@ def inner(f: T) -> T:
return inner(func)


def allowed_contexts(
guilds: bool = MISSING, dms: bool = MISSING, private_channels: bool = MISSING
) -> Union[T, Callable[[T], T]]:
def allowed_contexts(guilds: bool = MISSING, dms: bool = MISSING, private_channels: bool = MISSING) -> Callable[[T], T]:
"""A decorator that indicates this command can only be used in certain contexts.
Valid contexts are guilds, DMs and private channels.
Expand Down Expand Up @@ -2650,6 +2668,16 @@ def inner(f: T) -> T:
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]]:
"""A decorator that indicates this command should be installed in guilds.
Expand Down Expand Up @@ -2688,6 +2716,16 @@ def inner(f: T) -> T:
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]]:
"""A decorator that indicates this command should be installed for users.
Expand Down Expand Up @@ -2729,7 +2767,7 @@ def inner(f: T) -> T:
def allowed_installs(
guilds: 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.
Valid contexts are guilds and users.
Expand Down

0 comments on commit a1206df

Please sign in to comment.