-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (31 loc) · 1.13 KB
/
main.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
35
36
37
38
import discord
import os
from dotenv import load_dotenv
import util
load_dotenv()
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
channel = client.get_channel(int(os.getenv('CHANNEL_ID')))
if message.author == client.user:
return
mess = message.content.split(' ')
mess = mess[0].strip()
if message.channel == channel:
lastMsg = util.readFile()
if not mess.isnumeric():
await message.delete()
prompt = f"Message sent by {message.author.mention} was deleted because it violated game rules.\nLast valid count: {lastMsg}"
await channel.send(prompt)
else:
res = int(mess)- lastMsg
if res != 1:
await message.delete()
prompt = f"Message sent by {message.author.mention} was deleted because it violated game rules.\nLast valid count: {lastMsg}"
await channel.send(prompt)
else:
util.writeFile(str(lastMsg+1))
client.run(os.getenv('BOT_TOKEN'))