Skip to content

Commit 45ced59

Browse files
authored
Merge pull request #3340 from python-discord/jb3/mod-changes-refactor
Moderator changes minor refactor
2 parents 4b04acb + c226ea3 commit 45ced59

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

bot/exts/info/information.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,10 @@ async def rules(self, ctx: Context, *, args: str | None) -> set[int] | None:
691691

692692
if constants.Roles.helpers not in {role.id for role in ctx.author.roles}:
693693
# If the user is not a helper, send an alert to the rules thread.
694-
await self._send_rules_alert(ctx, sorted_rules)
694+
#
695+
# Exclude the bot commands channel to avoid spamming it with alerts.
696+
if ctx.channel.id != constants.Channels.bot_commands:
697+
await self._send_rules_alert(ctx, sorted_rules)
695698

696699
await LinePaginator.paginate(final_rules, ctx, rules_embed, max_lines=3)
697700

bot/exts/moderation/infraction/_scheduler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from discord.ext.commands import Context
1313
from pydis_core.site_api import ResponseCodeError
1414
from pydis_core.utils import scheduling
15-
from pydis_core.utils.channel import get_or_fetch_channel
1615

1716
from bot import constants
1817
from bot.bot import Bot
@@ -115,9 +114,9 @@ async def _delete_infraction_message(
115114
This is used to delete infraction messages after a certain period of time.
116115
"""
117116
try:
118-
channel = await get_or_fetch_channel(self.bot, channel_id)
119-
message = await channel.fetch_message(message_id)
120-
await message.delete()
117+
partial_channel = self.bot.get_partial_messageable(channel_id)
118+
partial_message = partial_channel.get_partial_message(message_id)
119+
await partial_message.delete()
121120
log.trace(f"Deleted infraction message {message_id} in channel {channel_id}.")
122121
except discord.NotFound:
123122
log.warning(f"Channel or message {message_id} not found in channel {channel_id}.")
@@ -322,7 +321,8 @@ async def apply_infraction(
322321
mentions = discord.AllowedMentions(users=[user], roles=False)
323322
sent_msg = await ctx.send(f"{dm_result}{confirm_msg}{infr_message}.", allowed_mentions=mentions)
324323

325-
if infraction["actor"] == self.bot.user.id:
324+
# Only tidy up bot issued infractions in non-mod channels.
325+
if infraction["actor"] == self.bot.user.id and not is_mod_channel(ctx.channel):
326326
expire_message_time = datetime.now(UTC) + timedelta(hours=AUTOMATED_TIDY_UP_HOURS)
327327

328328
log.trace(f"Scheduling message tidy for infraction #{id_} in {AUTOMATED_TIDY_UP_HOURS} hours.")

0 commit comments

Comments
 (0)