Skip to content

Commit 19c0668

Browse files
committed
unsnooze: suppress mentions during restore (AllowedMentions.none on replay and notifications)
1 parent 6181467 commit 19c0668

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

core/thread.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,24 @@ async def restore_from_snooze(self):
418418
else None
419419
),
420420
)
421-
await channel.send(embeds=embeds)
421+
await channel.send(
422+
embeds=embeds, allowed_mentions=discord.AllowedMentions.none()
423+
)
422424
else:
423425
formatted = (
424426
f"**{username} ({user_id})**: {content}"
425427
if content
426428
else f"**{username} ({user_id})**"
427429
)
428-
await channel.send(formatted)
430+
await channel.send(
431+
formatted, allowed_mentions=discord.AllowedMentions.none()
432+
)
429433
else:
430-
await channel.send(content=content or None, embeds=embeds or None)
434+
await channel.send(
435+
content=content or None,
436+
embeds=embeds or None,
437+
allowed_mentions=discord.AllowedMentions.none(),
438+
)
431439
self.snoozed = False
432440
# Store snooze_data for notification before clearing
433441
snooze_data_for_notify = self.snooze_data
@@ -458,18 +466,23 @@ async def restore_from_snooze(self):
458466
notify_channel = self.bot.config.get("unsnooze_notify_channel") or "thread"
459467
notify_text = self.bot.config.get("unsnooze_text") or "This thread has been unsnoozed and restored."
460468
if notify_channel == "thread":
461-
await channel.send(notify_text)
469+
await channel.send(
470+
notify_text, allowed_mentions=discord.AllowedMentions.none()
471+
)
462472
else:
463473
ch = self.bot.get_channel(int(notify_channel))
464474
if ch:
465-
await ch.send(f"Thread for user <@{self.id}> has been unsnoozed and restored.")
475+
await ch.send(
476+
f"Thread for user <@{self.id}> has been unsnoozed and restored.",
477+
allowed_mentions=discord.AllowedMentions.none(),
478+
)
466479
# Show who ran the snooze command and the command used
467480
# Use snooze_data_for_notify to avoid accessing self.snooze_data after it is set to None
468481
snoozed_by = snooze_data_for_notify.get("snoozed_by") if snooze_data_for_notify else None
469482
snooze_command = snooze_data_for_notify.get("snooze_command") if snooze_data_for_notify else None
470483
if snoozed_by or snooze_command:
471484
info = f"Snoozed by: {snoozed_by or 'Unknown'} | Command: {snooze_command or '?snooze'}"
472-
await channel.send(info)
485+
await channel.send(info, allowed_mentions=discord.AllowedMentions.none())
473486
return True
474487

475488
@classmethod

0 commit comments

Comments
 (0)