From 86da4f6e7004ae02e1f542219e5f822f1f8219db Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 19 Aug 2021 10:39:51 +0200 Subject: [PATCH] unload extension if timeout --- src/cogs/music.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cogs/music.py b/src/cogs/music.py index 0101138..e7e559a 100644 --- a/src/cogs/music.py +++ b/src/cogs/music.py @@ -44,7 +44,6 @@ genius.response_format = "markdown" def setup(client): client.add_cog(Music(client)) - # URL matching REGEX... URL_REG = re.compile(r'https?://(?:www\.)?.+') @@ -376,6 +375,11 @@ class Music(commands.Cog, wavelink.WavelinkMixin): sleep(1) # Port is open -> no service behind, retrying in 1 second... if timeout <= 0: + fileName = __file__.split("\\") # split for windows + if len(fileName) == 1: # if it wasn't windows + fileName = fileName[0].split("/") # split for linux + fileName = fileName[-1][:-3] # get file name and remove extension + self.bot.unload_extension(f"{self.bot.cogs_folder}.{fileName}") raise TimeoutError @wavelink.WavelinkMixin.listener()