Fix discord user is connected with pypresence
This commit is contained in:
@@ -72,8 +72,8 @@ if __name__ == "__main__":
|
||||
|
||||
# On récupère l'ID stocké (sera "" si absent grâce au schéma)
|
||||
stored_user_id = config.get_discord_user()
|
||||
if stored_user_id != "" or not stored_user_id.isspace():
|
||||
if not CheckDiscord.isuserconnected(stored_user_id):
|
||||
if stored_user_id != "" and not stored_user_id.isspace():
|
||||
if not CheckDiscord.isuserconnected():
|
||||
msg = CustomMessageBox(
|
||||
title="La Tanière: connexion Discord",
|
||||
message="Tu n'est pas connecté à Discord\n\n"
|
||||
|
||||
@@ -3,6 +3,7 @@ import psutil
|
||||
from pypresence import Presence
|
||||
from tools.get_server_token import GetServerTokenForDiscord
|
||||
from tools.constants import Urls
|
||||
from tools.discord_oauth import CLIENT_ID
|
||||
|
||||
class DiscordToken:
|
||||
@staticmethod
|
||||
@@ -23,15 +24,15 @@ class CheckDiscord:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def isuserconnected(clientid: str) -> bool:
|
||||
rpc = Presence(clientid)
|
||||
def isuserconnected() -> bool:
|
||||
rpc = Presence(CLIENT_ID)
|
||||
try:
|
||||
rpc.connect()
|
||||
return True
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
return False
|
||||
finally:
|
||||
try:
|
||||
rpc.close()
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user