diff options
| author | 2020-12-19 02:41:20 +0000 | |
|---|---|---|
| committer | 2020-12-19 02:41:20 +0000 | |
| commit | 9e61bed6bb3b8485c4b829a7072f4cea1e52e079 (patch) | |
| tree | 1d05acfa5227ccd027e00879924e3aa2fdd70d26 | |
| parent | Bump discord.py to a unreleased ref (diff) | |
Update verification.py to use on_member_update, closes #1330
| -rw-r--r-- | bot/exts/moderation/verification.py | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/bot/exts/moderation/verification.py b/bot/exts/moderation/verification.py index 581d7e0bf..ad05888df 100644 --- a/bot/exts/moderation/verification.py +++ b/bot/exts/moderation/verification.py @@ -570,9 +570,9 @@ class Verification(Cog): # If the user has the pending flag set, they will be using the alternate # gate and will not need a welcome DM with verification instructions. # We will send them an alternate DM once they verify with the welcome - # video. + # video when they pass the gate. if raw_member.get("pending"): - return self.pending_members.add(member.id) + return log.trace(f"Sending on join message to new member: {member.id}") try: @@ -581,33 +581,18 @@ class Verification(Cog): log.exception("DM dispatch failed on unexpected error code") @Cog.listener() - async def on_socket_response(self, msg: dict) -> None: - """Check if the users pending status has changed and send them them a welcome message.""" - if msg.get("t") == "GUILD_MEMBER_UPDATE": - user_id = int(msg["d"]["user"]["id"]) - - if msg["d"].get("pending") is False: - if user_id in self.pending_members: - self.pending_members.remove(user_id) - if member := self.bot.get_guild(constants.Guild.id).get_member(user_id): - await safe_dm(member.send(ALTERNATE_VERIFIED_MESSAGE)) - - @Cog.listener() async def on_member_update(self, before: discord.Member, after: discord.Member) -> None: """Check if we need to send a verification DM to a gated user.""" - before_roles = [role.id for role in before.roles] - after_roles = [role.id for role in after.roles] - - if constants.Roles.verified not in before_roles and constants.Roles.verified in after_roles: - if await self.member_gating_cache.pop(after.id): - try: - # If the member has not received a DM from our !accept command - # and has gone through the alternate gating system we should send - # our alternate welcome DM which includes info such as our welcome - # video. - await safe_dm(after.send(ALTERNATE_VERIFIED_MESSAGE)) - except discord.HTTPException: - log.exception("DM dispatch failed on unexpected error code") + + if before.pending is True and after.pending is False: + try: + # If the member has not received a DM from our !accept command + # and has gone through the alternate gating system we should send + # our alternate welcome DM which includes info such as our welcome + # video. + await safe_dm(after.send(ALTERNATE_VERIFIED_MESSAGE)) + except discord.HTTPException: + log.exception("DM dispatch failed on unexpected error code") @Cog.listener() async def on_message(self, message: discord.Message) -> None: |