unload extension if timeout

This commit is contained in:
Mylloon 2021-08-19 10:39:51 +02:00
parent 54933adf87
commit 86da4f6e70

View file

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