mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 16:32:59 +00:00
[commands] Respect enabled kwarg for hybrid app commands
This commit is contained in:
@@ -43,7 +43,7 @@ import inspect
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.utils import MISSING, maybe_coroutine, async_all
|
from discord.utils import MISSING, maybe_coroutine, async_all
|
||||||
from .core import Command, Group
|
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 .converter import Converter, Range, Greedy, run_converters, CONVERTER_MAPPING
|
||||||
from .parameters import Parameter
|
from .parameters import Parameter
|
||||||
from .flags import is_flag, FlagConverter
|
from .flags import is_flag, FlagConverter
|
||||||
@@ -526,6 +526,9 @@ class HybridCommand(Command[CogT, P, T]):
|
|||||||
self.app_command.binding = value
|
self.app_command.binding = value
|
||||||
|
|
||||||
async def can_run(self, ctx: Context[BotT], /) -> bool:
|
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:
|
if ctx.interaction is not None and self.app_command:
|
||||||
return await self.app_command._check_can_run(ctx.interaction)
|
return await self.app_command._check_can_run(ctx.interaction)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user