From da7e69a1b11dab9a5d99e89f06d09f8a92d6097f Mon Sep 17 00:00:00 2001 From: Blaise <133521603+blaise-tk@users.noreply.github.com> Date: Sat, 20 Jan 2024 00:42:54 +0100 Subject: [PATCH] fix discord presence --- assets/discord_presence.py | 45 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/assets/discord_presence.py b/assets/discord_presence.py index 4f9815138..b1eff732f 100644 --- a/assets/discord_presence.py +++ b/assets/discord_presence.py @@ -2,30 +2,35 @@ import datetime as dt import time - def rich_presence(): client_id = "1144714449563955302" RPC = Presence(client_id) - RPC.connect() - RPC.update( - state="applio.org", - details="Ultimate voice cloning tool.", - buttons=[ - {"label": "Home", "url": "https://applio.org"}, - {"label": "Download", "url": "https://applio.org/download"}, - ], - large_image="logo", - large_text="experimenting with applio", - start=dt.datetime.now().timestamp(), - ) - return RPC - + try: + RPC.connect() + RPC.update( + state="applio.org", + details="Ultimate voice cloning tool.", + buttons=[ + {"label": "Home", "url": "https://applio.org"}, + {"label": "Download", "url": "https://applio.org/download"}, + ], + large_image="logo", + large_text="experimenting with applio", + start=dt.datetime.now().timestamp(), + ) + return RPC + except Exception as e: + print(f"An error occurred: {e}") + return None if __name__ == "__main__": rpc = rich_presence() - try: - while True: - time.sleep(15) - except KeyboardInterrupt: - rpc.close() + if rpc: + try: + while True: + time.sleep(15) + except KeyboardInterrupt: + rpc.close() + else: + print("Failed to initialize Rich Presence.")