Fix some logic and make an actual example

This commit is contained in:
Gnome
2021-09-02 16:10:35 +01:00
parent 16ed293e00
commit ce16dc97ed
4 changed files with 48 additions and 65 deletions

View File

@@ -1144,17 +1144,21 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
:class:`bool`
A boolean indicating if the command can be invoked.
"""
if not self.enabled or (
ctx.interaction is None and (
self.message_command is False
or (self.message_command is None and not ctx.bot.message_commands)
) or (
self.slash_command is False
or (self.slash_command is None and not ctx.bot.slash_commands)
)
):
if not self.enabled:
raise DisabledCommand(f'{self.name} command is disabled')
if ctx.interaction is None and (
self.message_command is False
or (self.message_command is None and not ctx.bot.message_commands)
):
raise DisabledCommand(f'{self.name} command cannot be run as a message command')
if ctx.interaction is not None and (
self.slash_command is False
or (self.slash_command is None and not ctx.bot.slash_commands)
):
raise DisabledCommand(f'{self.name} command cannot be run as a slash command')
original = ctx.command
ctx.command = self