mirror of
https://github.com/Rapptz/discord.py.git
synced 2026-03-05 03:02:49 +00:00
Add generics to Interaction params
This commit is contained in:
@@ -1802,7 +1802,7 @@ class Group:
|
|||||||
yield from command.walk_commands()
|
yield from command.walk_commands()
|
||||||
|
|
||||||
@mark_overrideable
|
@mark_overrideable
|
||||||
async def on_error(self, interaction: Interaction, error: AppCommandError, /) -> None:
|
async def on_error(self, interaction: Interaction[ClientT], error: AppCommandError, /) -> None:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
A callback that is called when a child's command raises an :exc:`AppCommandError`.
|
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
|
self.on_error = coro # type: ignore
|
||||||
return coro
|
return coro
|
||||||
|
|
||||||
async def interaction_check(self, interaction: Interaction, /) -> bool:
|
async def interaction_check(self, interaction: Interaction[ClientT], /) -> bool:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
A callback that is called when an interaction happens within the group
|
A callback that is called when an interaction happens within the group
|
||||||
|
|||||||
@@ -646,7 +646,9 @@ class Cog(metaclass=CogMeta):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@_cog_special_method
|
@_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|
|
"""|coro|
|
||||||
|
|
||||||
A special method that is called whenever an error within
|
A special method that is called whenever an error within
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ if TYPE_CHECKING:
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from ..interactions import Interaction
|
from ..interactions import Interaction
|
||||||
|
from .._types import ClientT
|
||||||
from ..message import Message
|
from ..message import Message
|
||||||
from ..types.components import ComponentBase as ComponentBasePayload
|
from ..types.components import ComponentBase as ComponentBasePayload
|
||||||
from ..types.interactions import (
|
from ..types.interactions import (
|
||||||
@@ -485,7 +486,7 @@ class BaseView:
|
|||||||
"""
|
"""
|
||||||
return _utils_get(self.walk_children(), id=id)
|
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|
|
"""|coro|
|
||||||
|
|
||||||
A callback that is called when an interaction happens within the view
|
A callback that is called when an interaction happens within the view
|
||||||
@@ -520,7 +521,7 @@ class BaseView:
|
|||||||
"""
|
"""
|
||||||
pass
|
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|
|
"""|coro|
|
||||||
|
|
||||||
A callback that is called when an item's callback or :meth:`interaction_check`
|
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)
|
_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:
|
try:
|
||||||
item._refresh_state(interaction, interaction.data) # type: ignore
|
item._refresh_state(interaction, interaction.data) # type: ignore
|
||||||
|
|
||||||
@@ -574,7 +575,7 @@ class BaseView:
|
|||||||
self.__stopped.set_result(True)
|
self.__stopped.set_result(True)
|
||||||
asyncio.create_task(self.on_timeout(), name=f'discord-ui-view-timeout-{self.id}')
|
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():
|
if self.__stopped is None or self.__stopped.done():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -935,7 +936,7 @@ class ViewStore:
|
|||||||
self,
|
self,
|
||||||
component_type: int,
|
component_type: int,
|
||||||
factory: Type[DynamicItem[Item[Any]]],
|
factory: Type[DynamicItem[Item[Any]]],
|
||||||
interaction: Interaction,
|
interaction: Interaction[ClientT],
|
||||||
custom_id: str,
|
custom_id: str,
|
||||||
match: re.Match[str],
|
match: re.Match[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -986,7 +987,7 @@ class ViewStore:
|
|||||||
except Exception:
|
except Exception:
|
||||||
_log.exception('Ignoring exception in dynamic item callback for %r', item)
|
_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():
|
for pattern, item in self._dynamic_items.items():
|
||||||
match = pattern.fullmatch(custom_id)
|
match = pattern.fullmatch(custom_id)
|
||||||
if match is not None:
|
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)
|
self.dispatch_dynamic_items(component_type, custom_id, interaction)
|
||||||
interaction_id: Optional[int] = None
|
interaction_id: Optional[int] = None
|
||||||
message_id: Optional[int] = None
|
message_id: Optional[int] = None
|
||||||
@@ -1051,7 +1052,7 @@ class ViewStore:
|
|||||||
def dispatch_modal(
|
def dispatch_modal(
|
||||||
self,
|
self,
|
||||||
custom_id: str,
|
custom_id: str,
|
||||||
interaction: Interaction,
|
interaction: Interaction[ClientT],
|
||||||
components: List[ModalSubmitComponentInteractionDataPayload],
|
components: List[ModalSubmitComponentInteractionDataPayload],
|
||||||
resolved: ResolvedDataPayload,
|
resolved: ResolvedDataPayload,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user