Fix stopping
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 5s

This commit is contained in:
Nexus 2024-05-31 03:18:37 +01:00
parent e2ee0ff372
commit 9f4edd4b27
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -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(