From b5068bba6055dae8cddd28d8bd5b8e23b05f6d15 Mon Sep 17 00:00:00 2001 From: Matt Garofola Date: Sat, 17 Jun 2023 16:48:05 -0400 Subject: [PATCH] Removed code that ignores messages from other bots 'restart' command is now permitted by anyone --- redbot/cogs/audio/core/commands/audioset.py | 2 +- redbot/cogs/customcom/customcom.py | 2 +- redbot/core/bot.py | 55 ++++++++++----------- redbot/core/core_commands.py | 2 +- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/redbot/cogs/audio/core/commands/audioset.py b/redbot/cogs/audio/core/commands/audioset.py index 57194fd649ef..1e2ac210abe8 100644 --- a/redbot/cogs/audio/core/commands/audioset.py +++ b/redbot/cogs/audio/core/commands/audioset.py @@ -1458,7 +1458,7 @@ async def command_audioset_persist_queue(self, ctx: commands.Context): ) @command_audioset.command(name="restart") - @commands.is_owner() + # @commands.is_owner() async def command_audioset_restart(self, ctx: commands.Context): """Restarts the lavalink connection.""" async with ctx.typing(): diff --git a/redbot/cogs/customcom/customcom.py b/redbot/cogs/customcom/customcom.py index 7fefb36b713f..8245d04e4a82 100644 --- a/redbot/cogs/customcom/customcom.py +++ b/redbot/cogs/customcom/customcom.py @@ -646,7 +646,7 @@ async def on_message_without_command(self, message): if isinstance(message.channel, discord.PartialMessageable): return - if len(message.content) < 2 or is_private or not user_allowed or message.author.bot: + if len(message.content) < 2 or is_private or not user_allowed: return if await self.bot.cog_disabled_in_guild(self, message.guild): diff --git a/redbot/core/bot.py b/redbot/core/bot.py index f3a9135d6e5f..776a744373f3 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -822,8 +822,8 @@ async def message_eligible_as_command(self, message: discord.Message) -> bool: channel = message.channel guild = message.guild - if message.author.bot: - return False + # if message.author.bot: + # return False # We do not consider messages with PartialMessageable channel as eligible. # See `process_commands()` for our handling of it. @@ -1617,38 +1617,35 @@ async def process_commands(self, message: discord.Message, /): messages, without the overhead of additional get_context calls per cog. """ - 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 + 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 ( + if ( ctx.invoked_with and isinstance(message.channel, discord.PartialMessageable) and message.channel.type is not discord.ChannelType.private - ): - log.warning( - "Discarded a command message (ID: %s) with PartialMessageable channel: %r", - message.id, - message.channel, - ) - else: - await self.invoke(ctx) + ): + log.warning( + "Discarded a command message (ID: %s) with PartialMessageable channel: %r", + message.id, + message.channel, + ) else: - ctx = None + await self.invoke(ctx) if ctx is None or ctx.valid is False: self.dispatch("message_without_command", message) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index f1a483e555f2..53a75ce54a5d 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -2408,7 +2408,7 @@ async def _shutdown(self, ctx: commands.Context, silently: bool = False): await ctx.bot.shutdown() @commands.command(name="restart") - @commands.is_owner() + # @checks.is_owner() async def _restart(self, ctx: commands.Context, silently: bool = False): """Attempts to restart [botname].