[commands] Log exceptions that happen during cog_unload

This commit is contained in:
Rapptz 2023-09-20 17:20:50 -04:00
parent dacf3cfe86
commit 3f92f35bb1

View File

@ -25,6 +25,7 @@ from __future__ import annotations
import inspect import inspect
import discord import discord
import logging
from discord import app_commands from discord import app_commands
from discord.utils import maybe_coroutine, _to_kebab_case from discord.utils import maybe_coroutine, _to_kebab_case
@ -65,6 +66,7 @@ __all__ = (
FuncT = TypeVar('FuncT', bound=Callable[..., Any]) FuncT = TypeVar('FuncT', bound=Callable[..., Any])
MISSING: Any = discord.utils.MISSING MISSING: Any = discord.utils.MISSING
_log = logging.getLogger(__name__)
class CogMeta(type): class CogMeta(type):
@ -769,7 +771,7 @@ class Cog(metaclass=CogMeta):
try: try:
await maybe_coroutine(self.cog_unload) await maybe_coroutine(self.cog_unload)
except Exception: except Exception:
pass _log.exception('Ignoring exception in cog unload for Cog %r (%r)', cls, self.qualified_name)
class GroupCog(Cog): class GroupCog(Cog):