diff options
-rw-r--r-- | bot/exts/filters/filtering.py | 8 |
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) |