diff options
| author | 2020-12-19 01:40:11 +0000 | |
|---|---|---|
| committer | 2020-12-19 01:40:11 +0000 | |
| commit | a8a3e829c926694ba9e95fc712a9cfd5ccf84c2f (patch) | |
| tree | e39609fbbef5e3a86e873d8ea5e3b74e04686f76 | |
| parent | Update verification.py (diff) | |
Handling pending flag changes on users
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/moderation/verification.py | 26 | 
1 files changed, 14 insertions, 12 deletions
| diff --git a/bot/exts/moderation/verification.py b/bot/exts/moderation/verification.py index 7aa559617..ff308a3b3 100644 --- a/bot/exts/moderation/verification.py +++ b/bot/exts/moderation/verification.py @@ -182,6 +182,8 @@ class Verification(Cog):          self.bot = bot          self.bot.loop.create_task(self._maybe_start_tasks()) +        self.pending_members = set() +      def cog_unload(self) -> None:          """          Cancel internal tasks. @@ -570,18 +572,7 @@ class Verification(Cog):          # We will send them an alternate DM once they verify with the welcome          # video.          if raw_member.get("pending"): -            await self.member_gating_cache.set(member.id, True) - -            # TODO: Temporary, remove soon after asking joe. -            await self.mod_log.send_log_message( -                icon_url=self.bot.user.avatar_url, -                colour=discord.Colour.blurple(), -                title="New native gated user", -                channel_id=constants.Channels.user_log, -                text=f"<@{member.id}> ({member.id})", -            ) - -            return +            self.pending_members.add(member.id)          log.trace(f"Sending on join message to new member: {member.id}")          try: @@ -590,6 +581,17 @@ 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["user"]["id"]) + +            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] | 
