aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-08-26 22:26:15 +0200
committerGravatar kwzrd <[email protected]>2020-08-26 22:26:41 +0200
commit3672da9d6ad16452205e00a86162314f457fbbd0 (patch)
tree4004c9ffc4169355d401fcd93e20ce965a2e8061
parentVerification: retain ping in edited confirmation msg (diff)
Verification: add helper for alerting admins
-rw-r--r--bot/cogs/verification.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py
index d21395a1c..d5216c7c0 100644
--- a/bot/cogs/verification.py
+++ b/bot/cogs/verification.py
@@ -79,6 +79,7 @@ You will be kicked if you don't verify within `{KICKED_AFTER}` days.
REMINDER_FREQUENCY = 28 # Hours to wait between sending `REMINDER_MESSAGE`
+MENTION_ADMINS = discord.AllowedMentions(roles=[discord.Object(constants.Roles.admins)])
MENTION_CORE_DEVS = discord.AllowedMentions(roles=[discord.Object(constants.Roles.core_developers)])
MENTION_UNVERIFIED = discord.AllowedMentions(roles=[discord.Object(constants.Roles.unverified)])
@@ -239,6 +240,23 @@ class Verification(Cog):
return result
+ async def _alert_admins(self, exception: discord.HTTPException) -> None:
+ """
+ Ping @Admins with information about `exception`.
+
+ This is used when a critical `exception` caused a verification task to abort.
+ """
+ await self.bot.wait_until_guild_available()
+ log.info(f"Sending admin alert regarding exception: {exception}")
+
+ admins_channel = self.bot.get_guild(constants.Guild.id).get_channel(constants.Channels.admins)
+ ping = f"<@&{constants.Roles.admins}>"
+
+ await admins_channel.send(
+ f"{ping} Aborted updating unverified users due to the following exception:\n```{exception}```",
+ allowed_mentions=MENTION_ADMINS,
+ )
+
async def _send_requests(self, members: t.Collection[discord.Member], request: Request, limit: Limit) -> int:
"""
Pass `members` one by one to `request` handling Discord exceptions.