diff options
author | 2024-04-01 00:19:38 +0100 | |
---|---|---|
committer | 2024-04-01 00:19:38 +0100 | |
commit | d01f9d0d9ac6615d1bb622107564a3017d7b8ef8 (patch) | |
tree | 9d08814af94212d8c639bc5ca49066c2f5149d36 | |
parent | Merge pull request #2988 from python-discord/bump-bot-core (diff) | |
parent | Send log messages for voice gate pass and fail to #voice-log (diff) |
Merge pull request #2989 from python-discord/jb3/voice-gate-log-2922
Log to #voice-log for passed and failed attempts at voice verification
-rw-r--r-- | bot/exts/moderation/voice_gate.py | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/bot/exts/moderation/voice_gate.py b/bot/exts/moderation/voice_gate.py index 4244cce03..424f5f3d7 100644 --- a/bot/exts/moderation/voice_gate.py +++ b/bot/exts/moderation/voice_gate.py @@ -9,9 +9,11 @@ from pydis_core.site_api import ResponseCodeError from pydis_core.utils.channel import get_or_fetch_channel from bot.bot import Bot -from bot.constants import Channels, MODERATION_ROLES, Roles, VoiceGate as GateConf +from bot.constants import Channels, Icons, MODERATION_ROLES, Roles, VoiceGate as GateConf from bot.log import get_logger from bot.utils.checks import InWhitelistCheckFailure +from bot.utils.messages import format_user +from bot.utils.modlog import send_log_message log = get_logger(__name__) @@ -26,10 +28,10 @@ FAILED_MESSAGE = ( ) MESSAGE_FIELD_MAP = { - "joined_at": f"have been on the server for less than {GateConf.minimum_days_member} days", - "voice_gate_blocked": "have an active voice infraction", - "total_messages": f"have sent less than {GateConf.minimum_messages} messages", - "activity_blocks": f"have been active for fewer than {GateConf.minimum_activity_blocks} ten-minute blocks", + "joined_at": f"been on the server for less than {GateConf.minimum_days_member} days", + "voice_gate_blocked": "an active voice infraction", + "total_messages": f"sent less than {GateConf.minimum_messages} messages", + "activity_blocks": f"been active for fewer than {GateConf.minimum_activity_blocks} ten-minute blocks", } VOICE_PING = ( @@ -108,7 +110,9 @@ class VoiceVerificationView(discord.ui.View): embed = discord.Embed( title="Voice Gate failed", - description=FAILED_MESSAGE.format(reasons="\n".join(f"- You {reason}." for reason in failed_reasons)), + description=FAILED_MESSAGE.format( + reasons="\n".join(f"- You have {reason}." for reason in failed_reasons) + ), color=Colour.red() ) @@ -117,6 +121,19 @@ class VoiceVerificationView(discord.ui.View): ephemeral=True, delete_after=GateConf.delete_after_delay, ) + + log_reasons = "\n".join(f"- Has {reason}." for reason in failed_reasons) + + await send_log_message( + self.bot, + icon_url=Icons.defcon_denied, + colour=Colour.red(), + title="Voice gate failed", + text=f"{format_user(interaction.user)} failed the voice gate.\n\n{log_reasons}", + thumbnail=interaction.user.avatar, + channel_id=Channels.voice_log, + ) + return embed = discord.Embed( @@ -135,6 +152,17 @@ class VoiceVerificationView(discord.ui.View): delete_after=GateConf.delete_after_delay, ) await interaction.user.add_roles(discord.Object(Roles.voice_verified), reason="Voice Gate passed") + + await send_log_message( + self.bot, + icon_url=Icons.defcon_unshutdown, + colour=Colour.green(), + title="Voice gate passed", + text=f"{format_user(interaction.user)} passed the voice gate.", + thumbnail=interaction.user.avatar, + channel_id=Channels.voice_log, + ) + self.bot.stats.incr("voice_gate.passed") |