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
15 changes: 9 additions & 6 deletions capy_discord/exts/setup/_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class VerifyView(BaseView):
def __init__(
self,
*,
attempt_id: int,
target_user_id: int,
on_accept: Callable[[discord.Interaction, int], Awaitable[None]],
on_accept: Callable[[discord.Interaction, int, int], Awaitable[bool]],
on_timeout_callback: Callable[[int], Awaitable[None]],
timeout: float = 1800,
) -> None:
"""Initialize a verification view tied to one target user."""
super().__init__(timeout=timeout)
self.attempt_id = attempt_id
self.target_user_id = target_user_id
self._on_accept = on_accept
self._on_timeout_callback = on_timeout_callback
Expand All @@ -40,11 +42,12 @@ async def accept(self, interaction: discord.Interaction, _button: ui.Button) ->
)
return

await self._on_accept(interaction, self.target_user_id)
self.disable_all_items()
if self.message:
await self.message.edit(view=self)
self.stop()
completed = await self._on_accept(interaction, self.target_user_id, self.attempt_id)
if completed:
self.disable_all_items()
if self.message:
await self.message.edit(view=self)
self.stop()

async def on_timeout(self) -> None:
"""Mark state timeout and disable all controls when view expires."""
Expand Down
Loading
Loading