AntiScam.py added

AntiScam.py, the script with the function to prevent scamming, has been added.
This commit is contained in:
H3cJP 2021-11-15 22:26:19 +01:00 committed by GitHub
parent 8a81c8949f
commit 2d1f3d5989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

36
AntiScam.py Normal file
View File

@ -0,0 +1,36 @@
import discord
message_content = ''
last_message = ''
last_message_content = ''
spam_counter = 0
async def AntiScam(message, bot, whitelist, muted_role, verified_role, logs_channel):
global message_content, last_message, last_message_content, spam_counter
message_content = f'{message.author.id}: {message.content}'
message_content = message_content.replace("'", "`")
# AntiScam-System
if message_content == last_message_content and message.content != '' and message.author.id not in whitelist:
spam_counter += 1
await message.delete()
else:
last_message = message
last_message_content = message_content
spam_counter = 0
if len(message.mentions) > 10 and message.author.id not in whitelist:
await message.delete()
spam_counter = 2
if spam_counter > 1 and message.author.id not in whitelist:
spam_counter = 0
muted = discord.utils.get(message.author.guild.roles, name=muted_role)
verified = discord.utils.get(message.author.guild.roles, name=verified_role)
await last_message.delete()
await message.author.add_roles(muted)
await message.author.remove_roles(verified)
channel = bot.get_channel(logs_channel)
await channel.send(f'USUARIO MUTEADO: {message_content}')
await bot.process_commands(message)