Skip to content

Commit

Permalink
Removed code that ignores messages from other bots
Browse files Browse the repository at this point in the history
'restart' command is now permitted by anyone
  • Loading branch information
Matt Garofola authored and MatticusJee committed Dec 19, 2024
1 parent 9920628 commit dc7d2ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion redbot/cogs/audio/core/commands/audioset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,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():
Expand Down
2 changes: 1 addition & 1 deletion redbot/cogs/customcom/customcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
55 changes: 26 additions & 29 deletions redbot/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1621,38 +1621,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)
Expand Down
2 changes: 1 addition & 1 deletion redbot/core/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down

0 comments on commit dc7d2ac

Please sign in to comment.