-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
48 lines (42 loc) · 1.61 KB
/
bot.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
39
40
41
42
43
44
45
46
47
48
# bot.py
import os
import random
import discord
import asyncio
from dotenv import load_dotenv
from keep_alive import keep_alive
load_dotenv()
TOKEN = os.environ.get("DISCORD_TOKEN")
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
if message.author == client.user:
return
messages = await message.channel.history(limit=5).flatten()
for p in range(len(messages)):
if messages[p].author == client.user:
await messages[p].delete()
messages = await message.channel.history(limit=5).flatten()
try:
first = int(messages[0].content)
second = int(messages[1].content)
if (int(messages[0].content) != (int(messages[1].content) + 1)):
await messages[0].delete()
sent = await message.channel.send("This channel is for counting only. You entered " + messages[0].content + ". The previous number was " + messages[1].content)
await asyncio.sleep(3)
await sent.delete()
if (messages[0].author == messages[1].author):
await messages[0].delete()
sent = await message.channel.send("Please only enter one number at a time")
await asyncio.sleep(3)
await sent.delete()
except:
await messages[0].delete()
sent = await message.channel.send("This channel is for counting only. You entered " + messages[0].content + ". The previous number was " + messages[1].content)
await asyncio.sleep(3)
await sent.delete()
keep_alive()
client.run(TOKEN)