[Downloader] Unload extensions on uninstall (#2243)

Resolves #2216.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
Toby Harradine 2018-10-16 09:19:32 +11:00 committed by GitHub
parent b5fd28ef7c
commit aff62a8006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -325,13 +325,12 @@ class Downloader(commands.Cog):
You may only uninstall cogs which were previously installed You may only uninstall cogs which were previously installed
by Downloader. by Downloader.
""" """
# noinspection PyUnresolvedReferences,PyProtectedMember
real_name = cog.name real_name = cog.name
poss_installed_path = (await self.cog_install_path()) / real_name poss_installed_path = (await self.cog_install_path()) / real_name
if poss_installed_path.exists(): if poss_installed_path.exists():
ctx.bot.unload_extension(real_name)
await self._delete_cog(poss_installed_path) await self._delete_cog(poss_installed_path)
# noinspection PyTypeChecker
await self._remove_from_installed(cog) await self._remove_from_installed(cog)
await ctx.send( await ctx.send(
_("Cog `{cog_name}` was successfully uninstalled.").format(cog_name=real_name) _("Cog `{cog_name}` was successfully uninstalled.").format(cog_name=real_name)