mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Moved more things around
This commit is contained in:
parent
43d5bec4b7
commit
17a2250290
1 changed files with 9 additions and 10 deletions
19
main.py
19
main.py
|
@ -2,6 +2,8 @@ import asyncio
|
||||||
import discord
|
import discord
|
||||||
import json
|
import json
|
||||||
import overwatch
|
import overwatch
|
||||||
|
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
d_client = discord.Client()
|
d_client = discord.Client()
|
||||||
|
|
||||||
# Get player database from the db.json file
|
# Get player database from the db.json file
|
||||||
|
@ -9,22 +11,17 @@ file = open("db.json")
|
||||||
db = json.load(file)
|
db = json.load(file)
|
||||||
file.close()
|
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"
|
# Get the discord bot token from "discordtoken.txt"
|
||||||
f = open("discordtoken.txt", "r")
|
f = open("discordtoken.txt", "r")
|
||||||
token = f.read()
|
token = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Start discord bot client but ignore events
|
# 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
|
# List overwatch players
|
||||||
ow_players = list()
|
ow_players = list()
|
||||||
|
@ -32,3 +29,5 @@ for player in db:
|
||||||
if db[player]["overwatch"] is not None:
|
if db[player]["overwatch"] is not None:
|
||||||
ow_players.append(db[player]["overwatch"])
|
ow_players.append(db[player]["overwatch"])
|
||||||
|
|
||||||
|
# Connect to Discord
|
||||||
|
loop.run_until_complete(discord_connect())
|
||||||
|
|
Loading…
Reference in a new issue