"""import discord_rpc
import time

if __name__ == '__main__':
    def readyCallback(current_user):
        print('Our user: {}'.format(current_user))

    def disconnectedCallback(codeno, codemsg):
        print('Disconnected from Discord rich presence RPC. Code {}: {}'.format(
            codeno, codemsg
        ))

    def errorCallback(errno, errmsg):
        print('An error occurred! Error {}: {}'.format(
            errno, errmsg
        ))

    # Note: 'event_name': callback
    callbacks = {
        'ready': readyCallback,
        'disconnected': disconnectedCallback,
        'error': errorCallback,
    }
    discord_rpc.initialize('1063935289539694684', callbacks=callbacks, log=False)

    i = 0
    start = time.time()
    while True:
        i += 1

        discord_rpc.update_presence(
            **{
                "instance": False,
                "start_timestamp": start,
                'largeImageKey': 'icon',
                "large_image_text": "xxx",
                "small_image_key": "./images/logo_1.png"
            }
        )
        discord_rpc.update_connection()
        time.sleep(2)
        discord_rpc.run_callbacks()

    discord_rpc.shutdown()"""
from pypresence import Presence
import time
import json

start = int(time.time())
client_id = "1063935289539694684" #your application's client id
RPC = Presence(client_id)
RPC.connect()
state = ""

while True: #infinite loop
    with open("data/settings.json") as json_file:
        data = json.load(json_file)
        print(data["state"])
        state = data["state"]
    RPC.update(
        large_image = "icon", #name of your asset
        large_text = "Logo",
        state = state,
        start = start,
        buttons = [{"label": "Lien du projet", "url": "https://www-apps.univ-lehavre.fr/forge/pa220991/simon"}] #up to 2 buttons
    )
    time.sleep(1) #can be as low as 15, depends on how often you want to update