[commands] Respect enabled kwarg for hybrid app commands

This commit is contained in:
Soheab 2024-11-07 09:07:20 +01:00 committed by GitHub
parent af75985730
commit c7305b022c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,7 +43,7 @@ import inspect
from discord import app_commands
from discord.utils import MISSING, maybe_coroutine, async_all
from .core import Command, Group
from .errors import BadArgument, CommandRegistrationError, CommandError, HybridCommandError, ConversionError
from .errors import BadArgument, CommandRegistrationError, CommandError, HybridCommandError, ConversionError, DisabledCommand
from .converter import Converter, Range, Greedy, run_converters, CONVERTER_MAPPING
from .parameters import Parameter
from .flags import is_flag, FlagConverter
@ -526,6 +526,9 @@ class HybridCommand(Command[CogT, P, T]):
self.app_command.binding = value
async def can_run(self, ctx: Context[BotT], /) -> bool:
if not self.enabled:
raise DisabledCommand(f'{self.name} command is disabled')
if ctx.interaction is not None and self.app_command:
return await self.app_command._check_can_run(ctx.interaction)
else: