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

fix(cog): fix typing of cog check methods #1232

Merged
merged 2 commits into from
Aug 31, 2024
Merged
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
27 changes: 15 additions & 12 deletions disnake/ext/commands/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from disnake.interactions import ApplicationCommandInteraction

from ._types import MaybeCoro
from .bot import AutoShardedBot, AutoShardedInteractionBot, Bot, InteractionBot
from .context import Context
from .core import Command
Expand Down Expand Up @@ -491,7 +492,7 @@ def cog_unload(self) -> None:
pass

@_cog_special_method
def bot_check_once(self, ctx: Context) -> bool:
def bot_check_once(self, ctx: Context) -> MaybeCoro[bool]:
"""A special method that registers as a :meth:`.Bot.check_once`
check.

Expand All @@ -503,7 +504,7 @@ def bot_check_once(self, ctx: Context) -> bool:
return True

@_cog_special_method
def bot_check(self, ctx: Context) -> bool:
def bot_check(self, ctx: Context) -> MaybeCoro[bool]:
"""A special method that registers as a :meth:`.Bot.check`
check.

Expand All @@ -515,7 +516,7 @@ def bot_check(self, ctx: Context) -> bool:
return True

@_cog_special_method
def bot_slash_command_check_once(self, inter: ApplicationCommandInteraction) -> bool:
def bot_slash_command_check_once(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""A special method that registers as a :meth:`.Bot.slash_command_check_once`
check.

Expand All @@ -525,7 +526,7 @@ def bot_slash_command_check_once(self, inter: ApplicationCommandInteraction) ->
return True

@_cog_special_method
def bot_slash_command_check(self, inter: ApplicationCommandInteraction) -> bool:
def bot_slash_command_check(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""A special method that registers as a :meth:`.Bot.slash_command_check`
check.

Expand All @@ -535,27 +536,29 @@ def bot_slash_command_check(self, inter: ApplicationCommandInteraction) -> bool:
return True

@_cog_special_method
def bot_user_command_check_once(self, inter: ApplicationCommandInteraction) -> bool:
def bot_user_command_check_once(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""Similar to :meth:`.Bot.slash_command_check_once` but for user commands."""
return True

@_cog_special_method
def bot_user_command_check(self, inter: ApplicationCommandInteraction) -> bool:
def bot_user_command_check(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""Similar to :meth:`.Bot.slash_command_check` but for user commands."""
return True

@_cog_special_method
def bot_message_command_check_once(self, inter: ApplicationCommandInteraction) -> bool:
def bot_message_command_check_once(
self, inter: ApplicationCommandInteraction
) -> MaybeCoro[bool]:
"""Similar to :meth:`.Bot.slash_command_check_once` but for message commands."""
return True

@_cog_special_method
def bot_message_command_check(self, inter: ApplicationCommandInteraction) -> bool:
def bot_message_command_check(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""Similar to :meth:`.Bot.slash_command_check` but for message commands."""
return True

@_cog_special_method
def cog_check(self, ctx: Context) -> bool:
def cog_check(self, ctx: Context) -> MaybeCoro[bool]:
"""A special method that registers as a :func:`~.check`
for every text command and subcommand in this cog.

Expand All @@ -567,7 +570,7 @@ def cog_check(self, ctx: Context) -> bool:
return True

@_cog_special_method
def cog_slash_command_check(self, inter: ApplicationCommandInteraction) -> bool:
def cog_slash_command_check(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""A special method that registers as a :func:`~.check`
for every slash command and subcommand in this cog.

Expand All @@ -577,12 +580,12 @@ def cog_slash_command_check(self, inter: ApplicationCommandInteraction) -> bool:
return True

@_cog_special_method
def cog_user_command_check(self, inter: ApplicationCommandInteraction) -> bool:
def cog_user_command_check(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""Similar to :meth:`.Cog.cog_slash_command_check` but for user commands."""
return True

@_cog_special_method
def cog_message_command_check(self, inter: ApplicationCommandInteraction) -> bool:
def cog_message_command_check(self, inter: ApplicationCommandInteraction) -> MaybeCoro[bool]:
"""Similar to :meth:`.Cog.cog_slash_command_check` but for message commands."""
return True

Expand Down
Loading