mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 09:26:10 +00:00
[commands] Automatically unload top level app commands in extensions
This commit is contained in:
@ -38,6 +38,7 @@ from typing import Any, Callable, Mapping, List, Dict, TYPE_CHECKING, Optional,
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.app_commands.tree import _retrieve_guild_ids
|
||||
from discord.utils import MISSING, _is_submodule
|
||||
|
||||
from .core import GroupMixin
|
||||
from .view import StringView
|
||||
@ -65,8 +66,6 @@ __all__ = (
|
||||
'AutoShardedBot',
|
||||
)
|
||||
|
||||
MISSING: Any = discord.utils.MISSING
|
||||
|
||||
T = TypeVar('T')
|
||||
CFT = TypeVar('CFT', bound='CoroFunc')
|
||||
CXT = TypeVar('CXT', bound='Context')
|
||||
@ -120,10 +119,6 @@ def when_mentioned_or(*prefixes: str) -> Callable[[Union[Bot, AutoShardedBot], M
|
||||
return inner
|
||||
|
||||
|
||||
def _is_submodule(parent: str, child: str) -> bool:
|
||||
return parent == child or child.startswith(parent + ".")
|
||||
|
||||
|
||||
class _DefaultRepr:
|
||||
def __repr__(self):
|
||||
return '<default-help-command>'
|
||||
@ -724,6 +719,9 @@ class BotBase(GroupMixin):
|
||||
for index in reversed(remove):
|
||||
del event_list[index]
|
||||
|
||||
# remove all relevant application commands from the tree
|
||||
self.__tree._remove_with_module(name)
|
||||
|
||||
def _call_module_finalizers(self, lib: types.ModuleType, key: str) -> None:
|
||||
try:
|
||||
func = getattr(lib, 'teardown')
|
||||
|
Reference in New Issue
Block a user