[commands] Unload all extensions when gracefully closing bot.

This commit is contained in:
Rapptz 2016-12-17 14:04:28 -05:00
parent c7946606f4
commit bafaf72c89

View File

@ -266,6 +266,16 @@ class Bot(GroupMixin, discord.Client):
coro = self._run_extra(event, event_name, *args, **kwargs)
discord.compat.create_task(coro, loop=self.loop)
@asyncio.coroutine
def close(self):
for extension in self.extensions:
try:
self.unload_extension(extension)
except:
pass
yield from super().close()
@asyncio.coroutine
def on_command_error(self, exception, context):
"""|coro|