importtoxicityastox#this is a file called toxicity.py, which contains the toxicity function that allows you to check if a message is toxic or not (it uses the perspective api)
classModeration(discord.Cog):
def__init__(self,bot:discord.Bot)->None:
super().__init__()
self.bot=bot
@discord.slash_command(name="moderation",description="Enable or disable AI moderation & set the rules")
@discord.option(name="enable",description="Enable or disable AI moderation",reqired=True,)
@discord.option(name="log_channel",description="The channel where the moderation logs will be sent",required=True)
@discord.option(name="moderator_role",description="The role of the moderators",required=True)
awaitctx.respond("Our moderation capabilities have been switched to our new 100% free and open-source AI discord moderation bot! You add it to your server here: https://discord.com/api/oauth2/authorize?client_id=1071451913024974939&permissions=1377342450896&scope=bot and you can find the source code here: https://github.com/Paillat-dev/Moderator/ \n If you need help, you can join our support server here: https://discord.gg/pB6hXtUeDv")
ifenable==False:
c.execute("DELETE FROM moderation WHERE guild_id = ?",(str(ctx.guild.id),))
#we also do that with the manage_messages permission, so the moderators can't be moderated
ifmessage.author.guild_permissions.manage_messages:return#if the user is a moderator, we don't want to moderate him because he is allowed to say whatever he wants because he is just like a dictator
ifmessage.author.guild_permissions.administrator:return#if the user is an administrator, we don't want to moderate him because he is allowed to say whatever he wants because he is a DICTATOR
embed=discord.Embed(title="Message deleted",description=f"Your message was deleted because it was too toxic. The following reasons were found: **{'**, **'.join(reasons_to_delete)}**",color=discord.Color.red())
embed=discord.Embed(title="Message deleted",description=f"**{message.author}**'s message ***{content}*** was deleted because it was too toxic. The following reasons were found:",color=discord.Color.red())
awaitmessage.reply(f"{moderator_role.mention} This message might be toxic. The following reasons were found: **{'**, **'.join(reasons_to_suspicous)}**",delete_after=15,mention_author=False)
embed=discord.Embed(title="Message suspicious",description=f"**{message.author}**'s message [***{content}***]({message.jump_url}) might be toxic. The following reasons were found:",color=discord.Color.orange())
awaitctx.respond("Our moderation capabilities have been switched to our new 100% free and open-source AI discord moderation bot! You add it to your server here: https://discord.com/api/oauth2/authorize?client_id=1071451913024974939&permissions=1377342450896&scope=bot and you can find the source code here: https://discord.gg/pB6hXtUeDv . If you need help, you can join our support server here: https://discord.gg/pB6hXtUeDv")
awaitctx.respond("Our moderation capabilities have been switched to our new 100% free and open-source AI discord moderation bot! You add it to your server here: https://discord.com/api/oauth2/authorize?client_id=1071451913024974939&permissions=1377342450896&scope=bot and you can find the source code here: https://github.com/Paillat-dev/Moderator/ . If you need help, you can join our support server here: https://discord.gg/pB6hXtUeDv")