-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
40 lines (32 loc) · 1.1 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
import os
from web_scrape import *
from dates import *
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = discord.Client()
image = open('image.png', 'rb')
pfp = image.read()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
await client.user.edit(avatar=pfp)
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == '?dates':
reset_page_count()
await message.channel.send(current_page())
elif message.content == '?dates-next':
next_page()
await message.channel.send(current_page())
elif message.content == '?dates-prev':
prev_page()
await message.channel.send(current_page())
elif message.content == '?nearest':
await message.channel.send(format_nearest(find_nearest(str_to_dt(formatted('https://uwaterloo.ca/registrar/important-dates/list?academic_year=229&date=All&page=1')))))
elif message.content == '?help':
await message.channel.send(helpme())
client.run(TOKEN)