DM listed users when deadman is armed
This commit is contained in:
+31
-7
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user