diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 43e511a..d382b1d 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -23,6 +23,10 @@ intents = Intents.default() intents.members = True restart_ctx = None +invites = re.compile( + r"(https?://)?(www.)?(discord.(gg|io|me|li)|discordapp.com/invite)/([^\s/]+?)(?=\b)" +) + jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) @@ -173,6 +177,45 @@ async def on_message(message: Message): ) if autopurge: await message.delete(delay=autopurge["delay"]) + matches = invites.match(message.content) + if matches: + if matches.group(5) not in ["dbrand", "VtgZntXcnZ"]: + await message.delete() + db.jarvis.warns.insert_one( + { + "user": message.author.id, + "reason": "Sent an invite link", + "admin": get_config().client_id, + "time": datetime.now(), + "guild": message.guild.id, + "duration": 24, + "active": True, + } + ) + fields = [ + Field( + "Reason", + "Sent an invite link", + False, + ) + ] + embed = build_embed( + title="Warning", + description=f"{message.author.mention} has been warned", + fields=fields, + ) + embed.set_author( + name=message.author.nick + if message.author.nick + else message.author.name, + icon_url=message.author.avatar_url, + ) + embed.set_footer( + text=f"{message.author.name}#" + + f"{message.author.discriminator} " + + f"| {message.author.id}" + ) + await message.channel.send(embed=embed) await jarvis.process_commands(message) diff --git a/jarvis/cogs/starboard.py b/jarvis/cogs/starboard.py index 5f4ad68..1b1401a 100644 --- a/jarvis/cogs/starboard.py +++ b/jarvis/cogs/starboard.py @@ -241,6 +241,3 @@ class StarboardCog(commands.Cog): def setup(bot): bot.add_cog(StarboardCog(bot)) - - -cog(StarboardCog(bot))