forked from H3cJP/AntiScam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntiScam.py
34 lines (30 loc) · 1.35 KB
/
AntiScam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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("'", "`")
mentions = message.raw_mentions
# 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(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}')