Browse Source

[commands] Respect enabled kwarg for hybrid app commands

pull/10005/head
Soheab 5 months ago
committed by GitHub
parent
commit
c7305b022c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      discord/ext/commands/hybrid.py

5
discord/ext/commands/hybrid.py

@ -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:

Loading…
Cancel
Save