mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50:31 +00:00
[+] Added exception handling to query
This commit is contained in:
parent
c9c542dcbc
commit
46dcb39495
@ -6,6 +6,7 @@ from typing import Union
|
|||||||
import mcipc.query
|
import mcipc.query
|
||||||
import mcipc.query.client
|
import mcipc.query.client
|
||||||
|
|
||||||
|
import file_manager
|
||||||
import firebase_manager
|
import firebase_manager
|
||||||
|
|
||||||
|
|
||||||
@ -87,9 +88,13 @@ class MinecraftServerManager:
|
|||||||
def get_online_players(self, port) -> int:
|
def get_online_players(self, port) -> int:
|
||||||
if not self.servers[port]:
|
if not self.servers[port]:
|
||||||
return 0
|
return 0
|
||||||
|
try:
|
||||||
with mcipc.query.Client('127.0.0.1', port) as client:
|
with mcipc.query.Client('127.0.0.1', port) as client:
|
||||||
stats: int = client.stats(full=False).num_players
|
stats: int = client.stats(full=False).num_players
|
||||||
return stats
|
return stats
|
||||||
|
except Exception as e:
|
||||||
|
file_manager.log_error(type(e).__name__, str(e))
|
||||||
|
return 0
|
||||||
|
|
||||||
def set_cooldown(self, user_id):
|
def set_cooldown(self, user_id):
|
||||||
expiry_timestamp = time.time() + 30
|
expiry_timestamp = time.time() + 30
|
||||||
|
Loading…
Reference in New Issue
Block a user