Fix stopping
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 5s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 5s
This commit is contained in:
parent
e2ee0ff372
commit
9f4edd4b27
1 changed files with 5 additions and 3 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue