forked from CourseMatch-online/course-match
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
66 lines (54 loc) · 2.06 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import discord
import pyrebase
from discord.ext import commands
client = commands.Bot(command_prefix=">")
config = {
"apiKey": "AIzaSyDr1C2Ia5tigss8CC4dCzu4z7iZhV_QIdY",
"authDomain": "coursematch-828fc.firebaseapp.com",
"databaseURL": "https://coursematch-828fc-default-rtdb.firebaseio.com/",
"projectId": "coursematch-828fc",
"storageBucket": "coursematch-828fc.appspot.com",
"messagingSenderId": "968938856297",
"appId": "1:968938856297:web:8bef72d70dcf837348a7f8",
"measurementId": "G-M48V0YJQ81"
}
firebase = pyrebase.initialize_app(config)
database = firebase.database()
def getCourses(token):
data = database.child(token).get().val()
if data:
return data["courses"]
return None
def courseDoesNotExist(course, categories):
for cat in categories:
if (str(cat) == course):
return False
return True
@client.event
async def on_ready():
print('Bot is ready')
@client.command()
async def verify(ctx,number="noCode"):
courses = getCourses(number)
if(courses != None):
for course in courses:
guild = ctx.message.guild
if courseDoesNotExist(course,guild.categories):
category = await ctx.guild.create_category(course)
await guild.create_text_channel(course, category=category)
await guild.create_voice_channel(course, category=category)
for course in courses:
guild = ctx.message.guild
for cat in guild.categories:
if (str(cat) == course):
for ch in cat.channels:
await ch.set_permissions(ctx.author, read_messages=True,
send_messages=True)
elif(number=="noCode"):
await ctx.send("Please enter a verification number you bitch")
else:
await ctx.send("Wrong verification number you bitch")
x = await ctx.message.channel.create_invite()
print(x)
client.run("insertBotToken")