From 6774801649708e414860c60f8d2904ed7e9d9112 Mon Sep 17 00:00:00 2001 From: Flame442 <34169552+Flame442@users.noreply.github.com> Date: Sat, 18 Mar 2023 17:32:52 -0400 Subject: [PATCH] Always allow licenseinfo to be run with a mention prefix (#5865) Co-authored-by: Zephyrkul <23347632+Zephyrkul@users.noreply.github.com> --- redbot/core/bot.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 9c136117a..8baf2c46b 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -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",