diff options
| author | 2020-10-19 02:53:36 +1000 | |
|---|---|---|
| committer | 2020-10-19 02:53:36 +1000 | |
| commit | 5cc01bc834e8b89b21546870989afb93b11aa554 (patch) | |
| tree | 3eae48af3599d41fb1a6d1f95c7494b8580e1f10 | |
| parent | Merge pull request #1246 from python-discord/voice-gate-dm-failed (diff) | |
Ensure verified users can see verified message.
When verified users get their role, they cannot see the voice-verification channel anymore, so I've added a 3 second delay for granting the role in order to ensure there's some time for them to see the response.
I've also moved the DM message to only be sent if the DM message succeeds, and to not mention them in-channel to avoid distracting them from the DM notification unnecessarily, as I'm sure they'll see a near-instant response to their command usage in that channel.
| -rw-r--r-- | bot/exts/moderation/voice_gate.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bot/exts/moderation/voice_gate.py b/bot/exts/moderation/voice_gate.py index 8b68b8e2d..f158c2906 100644 --- a/bot/exts/moderation/voice_gate.py +++ b/bot/exts/moderation/voice_gate.py @@ -1,3 +1,4 @@ +import asyncio import logging from contextlib import suppress from datetime import datetime, timedelta @@ -50,9 +51,6 @@ class VoiceGate(Cog): - You must have accepted our rules over a certain number of days ago - You must not be actively banned from using our voice channels """ - # Send this as first thing in order to return after sending DM - await ctx.send(f"{ctx.author.mention}, check your DMs.") - try: data = await self.bot.api_client.get(f"bot/users/{ctx.author.id}/metricity_data") except ResponseCodeError as e: @@ -104,12 +102,12 @@ class VoiceGate(Cog): ) try: await ctx.author.send(embed=embed) + await ctx.send(f"{ctx.author}, please check your DMs.") except discord.Forbidden: await ctx.channel.send(ctx.author.mention, embed=embed) return self.mod_log.ignore(Event.member_update, ctx.author.id) - await ctx.author.add_roles(discord.Object(Roles.voice_verified), reason="Voice Gate passed") embed = discord.Embed( title="Voice gate passed", description="You have been granted permission to use voice channels in Python Discord.", @@ -117,8 +115,14 @@ class VoiceGate(Cog): ) try: await ctx.author.send(embed=embed) + await ctx.send(f"{ctx.author}, please check your DMs.") except discord.Forbidden: await ctx.channel.send(ctx.author.mention, embed=embed) + + # wait a little bit so those who don't get DMs see the response in-channel before losing perms to see it. + await asyncio.sleep(3) + await ctx.author.add_roles(discord.Object(Roles.voice_verified), reason="Voice Gate passed") + self.bot.stats.incr("voice_gate.passed") @Cog.listener() |