From 9f4edd4b27453a9af433992cc9208bc3fa100669 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Fri, 31 May 2024 03:18:37 +0100 Subject: [PATCH] Fix stopping --- src/cogs/ytdl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cogs/ytdl.py b/src/cogs/ytdl.py index fd29832..74b0bc7 100644 --- a/src/cogs/ytdl.py +++ b/src/cogs/ytdl.py @@ -266,8 +266,8 @@ class YTDLCog(commands.Cog): stop = asyncio.Event() def _download_hook(_data: dict[str, typing.Any]): - if stop.set(): - raise RuntimeError("Download cancelled.") + if stop.is_set(): + raise ValueError("Download cancelled.") n = time.time() _total = _data.get("total_bytes", _data.get("total_bytes_estimate")) or ctx.guild.filesize_limit if _total: @@ -407,7 +407,9 @@ class YTDLCog(commands.Cog): @discord.ui.button(label="Cancel download", style=discord.ButtonStyle.danger) async def _stop(self, button: discord.ui.Button, interaction: discord.Interaction): stop.set() - await interaction.response.edit_message(view=None) + button.label = "Cancelling..." + button.disabled = True + await interaction.response.edit_message(view=self) self.stop() await ctx.edit(