aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar GDWR <[email protected]>2022-02-01 19:19:33 +0000
committerGravatar GDWR <[email protected]>2022-02-01 19:19:33 +0000
commitc51fb9c9c98b02c393ae56867d4365b41cd3f77d (patch)
tree407106c0d52596cb8f90c4d0cff347d6e954705e
parent🚸 Ping moderators when a bad username is detected (diff)
✨ Check for bad username when user joins or switches voice channel
-rw-r--r--bot/exts/filters/filtering.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py
index 0ac6dfe51..7b708f9a9 100644
--- a/bot/exts/filters/filtering.py
+++ b/bot/exts/filters/filtering.py
@@ -12,7 +12,7 @@ import tldextract
from async_rediscache import RedisCache
from botcore.regex import DISCORD_INVITE
from dateutil.relativedelta import relativedelta
-from discord import Colour, HTTPException, Member, Message, NotFound, TextChannel
+from discord import Colour, HTTPException, Member, Message, NotFound, TextChannel, VoiceState
from discord.ext.commands import Cog
from discord.utils import escape_markdown
@@ -207,6 +207,12 @@ class Filtering(Cog):
delta = relativedelta(after.edited_at, before.edited_at).microseconds
await self._filter_message(after, delta)
+ @Cog.listener()
+ async def on_voice_state_update(self, member: Member, before: VoiceState, after: VoiceState):
+ """When a member initially joins a voice channel or switches to a new one, check for a bad name in username."""
+ if after.channel and not before.channel:
+ await self.check_bad_words_in_name(member)
+
def get_name_match(self, name: str) -> Optional[re.Match]:
"""Check bad words from passed string (name). Return the first match found."""
normalised_name = unicodedata.normalize("NFKC", name)