Acknowledge watch party panel interactions immediately

This commit is contained in:
MiTHRAL 2026-05-26 15:47:33 -04:00
parent 42c9101a9f
commit 536ea2eff1

View file

@ -302,6 +302,11 @@ class DiscordGatewayManager:
else: else:
await interaction.response.send_message(message, ephemeral=True) await interaction.response.send_message(message, ephemeral=True)
async def defer_then(interaction: Any, action) -> None:
if not interaction.response.is_done():
await interaction.response.defer(ephemeral=True)
await action()
async def do_create(interaction: Any, title: str | None = None) -> None: async def do_create(interaction: Any, title: str | None = None) -> None:
voice_channel = ensure_voice_context(interaction) voice_channel = ensure_voice_context(interaction)
session = session_for_voice(interaction) session = session_for_voice(interaction)
@ -377,7 +382,7 @@ class DiscordGatewayManager:
async def on_submit(self, interaction: Any) -> None: async def on_submit(self, interaction: Any) -> None:
try: try:
await do_add(interaction, str(self.query.value), str(self.media_type.value or "all")) await defer_then(interaction, lambda: do_add(interaction, str(self.query.value), str(self.media_type.value or "all")))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@ -388,7 +393,7 @@ class DiscordGatewayManager:
@discord.ui.button(label="Create", style=discord.ButtonStyle.primary, custom_id=WATCH_PARTY_PANEL_CREATE_ID) @discord.ui.button(label="Create", style=discord.ButtonStyle.primary, custom_id=WATCH_PARTY_PANEL_CREATE_ID)
async def create_button(self, interaction: Any, _button: Any) -> None: async def create_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_create(interaction, None) await defer_then(interaction, lambda: do_create(interaction, None))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@ -399,42 +404,42 @@ class DiscordGatewayManager:
@discord.ui.button(label="Start", style=discord.ButtonStyle.success, custom_id=WATCH_PARTY_PANEL_START_ID) @discord.ui.button(label="Start", style=discord.ButtonStyle.success, custom_id=WATCH_PARTY_PANEL_START_ID)
async def start_button(self, interaction: Any, _button: Any) -> None: async def start_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_start(interaction) await defer_then(interaction, lambda: do_start(interaction))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@discord.ui.button(label="Queue", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_QUEUE_ID) @discord.ui.button(label="Queue", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_QUEUE_ID)
async def queue_button(self, interaction: Any, _button: Any) -> None: async def queue_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_queue(interaction) await defer_then(interaction, lambda: do_queue(interaction))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@discord.ui.button(label="Status", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_STATUS_ID) @discord.ui.button(label="Status", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_STATUS_ID)
async def status_button(self, interaction: Any, _button: Any) -> None: async def status_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_status(interaction) await defer_then(interaction, lambda: do_status(interaction))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@discord.ui.button(label="Pause", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_PAUSE_ID, row=1) @discord.ui.button(label="Pause", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_PAUSE_ID, row=1)
async def pause_button(self, interaction: Any, _button: Any) -> None: async def pause_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_control(interaction, "pause", {}) await defer_then(interaction, lambda: do_control(interaction, "pause", {}))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@discord.ui.button(label="Resume", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_RESUME_ID, row=1) @discord.ui.button(label="Resume", style=discord.ButtonStyle.secondary, custom_id=WATCH_PARTY_PANEL_RESUME_ID, row=1)
async def resume_button(self, interaction: Any, _button: Any) -> None: async def resume_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_control(interaction, "resume", {}) await defer_then(interaction, lambda: do_control(interaction, "resume", {}))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))
@discord.ui.button(label="Stop", style=discord.ButtonStyle.danger, custom_id=WATCH_PARTY_PANEL_STOP_ID, row=1) @discord.ui.button(label="Stop", style=discord.ButtonStyle.danger, custom_id=WATCH_PARTY_PANEL_STOP_ID, row=1)
async def stop_button(self, interaction: Any, _button: Any) -> None: async def stop_button(self, interaction: Any, _button: Any) -> None:
try: try:
await do_control(interaction, "stop", {}) await defer_then(interaction, lambda: do_control(interaction, "stop", {}))
except Exception as exc: except Exception as exc:
await respond(interaction, str(exc)) await respond(interaction, str(exc))