Skip to content
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
4 changes: 2 additions & 2 deletions discord/app_commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ def walk_commands(self) -> Generator[Union[Command[Any, ..., Any], Group], None,
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`.
Expand Down Expand Up @@ -1850,7 +1850,7 @@ def error(self, coro: ErrorFunc) -> ErrorFunc:
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
Expand Down
4 changes: 3 additions & 1 deletion discord/ext/commands/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ async def cog_command_error(self, ctx: Context[BotT], error: Exception) -> None:
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
Expand Down
17 changes: 9 additions & 8 deletions discord/ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
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 (
Expand Down Expand Up @@ -485,7 +486,7 @@ def find_item(self, id: int, /) -> Optional[Item[Self]]:
"""
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
Expand Down Expand Up @@ -520,7 +521,7 @@ async def on_timeout(self) -> None:
"""
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`
Expand All @@ -539,7 +540,7 @@ async def on_error(self, interaction: Interaction, error: Exception, item: Item[
"""
_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

Expand Down Expand Up @@ -574,7 +575,7 @@ def _dispatch_timeout(self):
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

Expand Down Expand Up @@ -935,7 +936,7 @@ async def schedule_dynamic_item_call(
self,
component_type: int,
factory: Type[DynamicItem[Item[Any]]],
interaction: Interaction,
interaction: Interaction[ClientT],
custom_id: str,
match: re.Match[str],
) -> None:
Expand Down Expand Up @@ -986,7 +987,7 @@ async def schedule_dynamic_item_call(
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:
Expand All @@ -997,7 +998,7 @@ def dispatch_dynamic_items(self, component_type: int, custom_id: str, interactio
)
)

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
Expand Down Expand Up @@ -1051,7 +1052,7 @@ def dispatch_view(self, component_type: int, custom_id: str, interaction: Intera
def dispatch_modal(
self,
custom_id: str,
interaction: Interaction,
interaction: Interaction[ClientT],
components: List[ModalSubmitComponentInteractionDataPayload],
resolved: ResolvedDataPayload,
) -> None:
Expand Down
Loading