diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index cc0aaef9b..da8879827 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -1802,7 +1802,7 @@ class Group: yield from command.walk_commands() @mark_overrideable - async def on_error(self, interaction: Interaction, error: AppCommandError, /) -> None: + async def on_error(self, interaction: Interaction[ClientT], error: AppCommandError, /) -> None: """|coro| A callback that is called when a child's command raises an :exc:`AppCommandError`. @@ -1850,7 +1850,7 @@ class Group: self.on_error = coro # type: ignore return coro - async def interaction_check(self, interaction: Interaction, /) -> bool: + async def interaction_check(self, interaction: Interaction[ClientT], /) -> bool: """|coro| A callback that is called when an interaction happens within the group diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 4b2f2c2fa..e229345cc 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -646,7 +646,9 @@ class Cog(metaclass=CogMeta): pass @_cog_special_method - async def cog_app_command_error(self, interaction: discord.Interaction, error: app_commands.AppCommandError) -> None: + async def cog_app_command_error( + self, interaction: discord.Interaction[ClientT], error: app_commands.AppCommandError + ) -> None: """|coro| A special method that is called whenever an error within diff --git a/discord/ui/view.py b/discord/ui/view.py index 6b4a3ca90..57b0e2229 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -82,6 +82,7 @@ if TYPE_CHECKING: import re from ..interactions import Interaction + from .._types import ClientT from ..message import Message from ..types.components import ComponentBase as ComponentBasePayload from ..types.interactions import ( @@ -485,7 +486,7 @@ class BaseView: """ return _utils_get(self.walk_children(), id=id) - async def interaction_check(self, interaction: Interaction, /) -> bool: + async def interaction_check(self, interaction: Interaction[ClientT], /) -> bool: """|coro| A callback that is called when an interaction happens within the view @@ -520,7 +521,7 @@ class BaseView: """ pass - async def on_error(self, interaction: Interaction, error: Exception, item: Item[Any], /) -> None: + async def on_error(self, interaction: Interaction[ClientT], error: Exception, item: Item[Any], /) -> None: """|coro| A callback that is called when an item's callback or :meth:`interaction_check` @@ -539,7 +540,7 @@ class BaseView: """ _log.error('Ignoring exception in view %r for item %r', self, item, exc_info=error) - async def _scheduled_task(self, item: Item, interaction: Interaction): + async def _scheduled_task(self, item: Item[Any], interaction: Interaction[ClientT]): try: item._refresh_state(interaction, interaction.data) # type: ignore @@ -574,7 +575,7 @@ class BaseView: self.__stopped.set_result(True) asyncio.create_task(self.on_timeout(), name=f'discord-ui-view-timeout-{self.id}') - def _dispatch_item(self, item: Item, interaction: Interaction) -> Optional[asyncio.Task[None]]: + def _dispatch_item(self, item: Item[Any], interaction: Interaction[ClientT]) -> Optional[asyncio.Task[None]]: if self.__stopped is None or self.__stopped.done(): return None @@ -935,7 +936,7 @@ class ViewStore: self, component_type: int, factory: Type[DynamicItem[Item[Any]]], - interaction: Interaction, + interaction: Interaction[ClientT], custom_id: str, match: re.Match[str], ) -> None: @@ -986,7 +987,7 @@ class ViewStore: except Exception: _log.exception('Ignoring exception in dynamic item callback for %r', item) - def dispatch_dynamic_items(self, component_type: int, custom_id: str, interaction: Interaction) -> None: + def dispatch_dynamic_items(self, component_type: int, custom_id: str, interaction: Interaction[ClientT]) -> None: for pattern, item in self._dynamic_items.items(): match = pattern.fullmatch(custom_id) if match is not None: @@ -997,7 +998,7 @@ class ViewStore: ) ) - def dispatch_view(self, component_type: int, custom_id: str, interaction: Interaction) -> None: + def dispatch_view(self, component_type: int, custom_id: str, interaction: Interaction[ClientT]) -> None: self.dispatch_dynamic_items(component_type, custom_id, interaction) interaction_id: Optional[int] = None message_id: Optional[int] = None @@ -1051,7 +1052,7 @@ class ViewStore: def dispatch_modal( self, custom_id: str, - interaction: Interaction, + interaction: Interaction[ClientT], components: List[ModalSubmitComponentInteractionDataPayload], resolved: ResolvedDataPayload, ) -> None: