Skip to content

Commit 765b2e6

Browse files
authored
Merge pull request #310 from practical-python-org/fix/invite_spam_and_automod_spam_fixes
Fix/invite spam and automod spam fixes
2 parents dc46f7d + 3adaac3 commit 765b2e6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/zorak/cogs/admin/admin_automod_spam_messages.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ async def on_message(self, message):
3535
# Dont catch Zorak
3636
if message.author.bot:
3737
return
38+
# Dont care about DM channels
39+
if isinstance(message.channel, discord.DMChannel):
40+
return
3841

3942
# new speaker. Welcome to auto mod.
4043
if message.author.id not in self.records:

src/zorak/cogs/admin/moderation_invites.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def log_message(arg_message):
5151
author = arg_message.author
5252
embed = discord.Embed(
5353
title="<:red_circle:1043616578744357085> Invite removed",
54-
description=f"Posted by {arg_message.author}\nIn {arg_message.channel.mention}",
54+
description=f"Posted by {arg_message.author}\nIn {'a DM.' if isinstance(arg_message.channel, discord.DMChannel) else arg_message.channel.mention}",
5555
color=discord.Color.dark_red(),
5656
timestamp=datetime.utcnow(),
5757
)
@@ -70,8 +70,8 @@ def embed_warning(arg_message):
7070
embed = discord.Embed(
7171
title="<:x:1055080113336762408> External Invites are not allowed here!",
7272
description=f"{arg_message.author}, your message was removed "
73-
f"because it contained an external invite.\nIf this "
74-
f"was a mistake, contact the @staff",
73+
f"because it contained an external invite.\nIf this "
74+
f"was a mistake, contact the @staff",
7575
color=discord.Color.dark_red(),
7676
timestamp=datetime.utcnow(),
7777
)
@@ -87,6 +87,9 @@ def check_for_admin_override(arg_message):
8787
return any(role.id in self.bot.server_settings.admin_roles.values() for role in message.author.roles)
8888

8989
if is_invite(txt):
90+
if isinstance(message.channel, discord.DMChannel):
91+
return
92+
9093
if not check_for_admin_override(txt):
9194
logs_channel = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
9295
await logs_channel.send(embed=log_message(message))

0 commit comments

Comments
 (0)