2016-08-12 13:55:59 +00:00
|
|
|
import asyncio
|
|
|
|
import discord
|
2016-08-12 15:23:45 +00:00
|
|
|
import json
|
|
|
|
import overwatch
|
|
|
|
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:21:14 +00:00
|
|
|
# When the discord client is ready, print something
|
2016-08-12 15:23:45 +00:00
|
|
|
@d_client.event
|
2016-08-12 13:55:59 +00:00
|
|
|
async def on_ready():
|
|
|
|
print("Connessione riuscita!")
|
2016-08-12 15:23:45 +00:00
|
|
|
print(d_client.user.name)
|
|
|
|
print(d_client.user.id)
|
|
|
|
|
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:23:45 +00:00
|
|
|
d_client.start(token)
|
|
|
|
|
|
|
|
# List overwatch players
|
|
|
|
ow_players = list()
|
|
|
|
for player in db:
|
|
|
|
if db[player]["overwatch"] is not None:
|
|
|
|
ow_players.append(db[player]["overwatch"])
|
|
|
|
|