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