2016-08-12 13:55:59 +00:00
|
|
|
import asyncio
|
|
|
|
import discord
|
2016-08-12 15:23:45 +00:00
|
|
|
import json
|
|
|
|
import overwatch
|
2016-08-12 15:48:35 +00:00
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
2016-08-12 15:23:45 +00:00
|
|
|
d_client = discord.Client()
|
|
|
|
|
|
|
|
# Get player database from the db.json file
|
|
|
|
file = open("db.json")
|
|
|
|
db = json.load(file)
|
|
|
|
file.close()
|
2016-08-12 13:55:59 +00:00
|
|
|
|
2016-08-12 14:01:05 +00:00
|
|
|
# Get the discord bot token from "discordtoken.txt"
|
|
|
|
f = open("discordtoken.txt", "r")
|
|
|
|
token = f.read()
|
|
|
|
f.close()
|
|
|
|
|
2016-08-12 14:21:14 +00:00
|
|
|
# Start discord bot client but ignore events
|
2016-08-12 15:48:35 +00:00
|
|
|
async def discord_connect():
|
|
|
|
await d_client.login(token)
|
|
|
|
print("Discord login was successful!")
|
|
|
|
d_client.connect() # Something's not right here...
|
|
|
|
print("Discord connection was successful!")
|
2016-08-12 15:23:45 +00:00
|
|
|
|
|
|
|
# List overwatch players
|
|
|
|
ow_players = list()
|
|
|
|
for player in db:
|
|
|
|
if db[player]["overwatch"] is not None:
|
|
|
|
ow_players.append(db[player]["overwatch"])
|
|
|
|
|
2016-08-12 15:48:35 +00:00
|
|
|
# Connect to Discord
|
|
|
|
loop.run_until_complete(discord_connect())
|