mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40: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.client
|
||||
|
||||
import file_manager
|
||||
import firebase_manager
|
||||
|
||||
|
||||
@ -87,9 +88,13 @@ class MinecraftServerManager:
|
||||
def get_online_players(self, port) -> int:
|
||||
if not self.servers[port]:
|
||||
return 0
|
||||
try:
|
||||
with mcipc.query.Client('127.0.0.1', port) as client:
|
||||
stats: int = client.stats(full=False).num_players
|
||||
return stats
|
||||
except Exception as e:
|
||||
file_manager.log_error(type(e).__name__, str(e))
|
||||
return 0
|
||||
|
||||
def set_cooldown(self, user_id):
|
||||
expiry_timestamp = time.time() + 30
|
||||
|
Loading…
Reference in New Issue
Block a user