From 17a2250290548b29908a5c7ae51fbb61a7e753a7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 12 Aug 2016 17:48:35 +0200 Subject: [PATCH] Moved more things around --- main.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 8dec571b..510bd4a7 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,8 @@ import asyncio import discord import json import overwatch + +loop = asyncio.get_event_loop() d_client = discord.Client() # Get player database from the db.json file @@ -9,22 +11,17 @@ file = open("db.json") db = json.load(file) file.close() - -# When the discord client is ready, print something -@d_client.event -async def on_ready(): - print("Connessione riuscita!") - print(d_client.user.name) - print(d_client.user.id) - - # Get the discord bot token from "discordtoken.txt" f = open("discordtoken.txt", "r") token = f.read() f.close() # Start discord bot client but ignore events -d_client.start(token) +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!") # List overwatch players ow_players = list() @@ -32,3 +29,5 @@ for player in db: if db[player]["overwatch"] is not None: ow_players.append(db[player]["overwatch"]) +# Connect to Discord +loop.run_until_complete(discord_connect())