Always allow licenseinfo to be run with a mention prefix (#5865)

Co-authored-by: Zephyrkul <23347632+Zephyrkul@users.noreply.github.com>
This commit is contained in:
Flame442 2023-03-18 17:32:52 -04:00 committed by GitHub
parent 7c7e5edb19
commit 6774801649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1589,6 +1589,22 @@ class Red(
"""
if not message.author.bot:
ctx = await self.get_context(message)
# The licenseinfo command must always be available, even in a slash only bot.
# To get around not having the message content intent, a mention prefix
# will always work for it.
if not ctx.valid:
for m in (f"<@{self.user.id}> ", f"<@!{self.user.id}> "):
if message.content.startswith(m):
ctx.view.undo()
ctx.view.skip_string(m)
invoker = ctx.view.get_word()
command = self.all_commands.get(invoker, None)
if isinstance(command, commands.commands._AlwaysAvailableMixin):
ctx.command = command
ctx.prefix = m
break
if ctx.invoked_with and isinstance(message.channel, discord.PartialMessageable):
log.warning(
"Discarded a command message (ID: %s) with PartialMessageable channel: %r",