DM listed users when deadman is armed

This commit is contained in:
2026-09-07 15:49:17 -05:00
parent 9cc3b1ecc1
commit e0ff129b6b
2 changed files with 32 additions and 8 deletions
+31 -7
View File
@@ -194,13 +194,37 @@ class Deadman(commands.Cog):
self._triggered = False
expires_str = expires_at.strftime("%Y-%m-%d %H:%M UTC")
await ctx.send(
f"Deadman switch ARMED.\n"
f"Expires: **{expires_str}** (in {duration_td})\n"
f"Users notified: {', '.join(u.mention for u in users)}\n"
+ (f"Alert channel: {trigger_channel.mention}\n" if trigger_channel else "\n")
+ "Run `[p]deadman disable` before that time to cancel."
)
notified = 0
failed = []
for user in users:
try:
await user.send(
f"**Deadman switch armed**\n"
f"You have been added to a deadman switch.\n"
f"It expires at **{expires_str}**.\n"
f"If it is not disabled before then, you will receive a TRIGGERED alert.\n"
f"Contact the bot owner if this is a mistake."
)
notified += 1
except discord.Forbidden:
failed.append(user)
except Exception:
failed.append(user)
status_parts = [
f"Deadman switch ARMED.",
f"Expires: **{expires_str}** (in {duration_td})",
f"Users notified: {', '.join(u.mention for u in users)}",
]
if trigger_channel:
status_parts.append(f"Alert channel: {trigger_channel.mention}")
status_parts.append(f"DM'd {notified} of {len(users)} user(s).")
if failed:
status_parts.append(
"Could not DM: " + ", ".join(u.mention for u in failed)
)
status_parts.append("Run `[p]deadman disable` before that time to cancel.")
await ctx.send("\n".join(status_parts))
@deadman.command(name="disable")
async def deadman_disable(self, ctx):