Update server_commands.py

This commit is contained in:
Elmon11 2021-03-30 01:17:46 +02:00 committed by GitHub
parent 5e77dee33f
commit f03c91e9e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,8 +5,9 @@ import discord
import requests
from discord.ext import commands
from checks import is_liaison, is_staff, is_senior, is_creative_designer, is_mod_or_has_perms, NoPermission, is_dev, is_gmod_owner, is_smp_owner, notAdminCommand
from functions import hit_endpoint, get_server_status, format_list_entry, read_json
from checks import is_liaison, is_staff, is_senior, is_creative_designer, is_mod_or_has_perms, NoPermission, is_dev, \
is_gmod_owner, is_smp_owner, notAdminCommand
from functions import hit_endpoint, get_server_status, format_list_entry, read_json, get_visible_player_count
from unicode import clipboard
@ -124,7 +125,7 @@ class ServerCommands(commands.Cog, name="Server Commands"):
except Exception as e:
em.title = 'Command error'
em.colour = 0xFF0000
print(f'Error while starting freedom-0{server}: {e}')
print(f'Error while getting VPS Uptime: {e}')
em.description = f'Something went wrong'
else:
em.description = attempt
@ -308,7 +309,6 @@ class ServerCommands(commands.Cog, name="Server Commands"):
if json["online"] == 0:
em.description = "There are no online players"
else:
em.description = f"There are {json['online']} / {json['max']} online players"
ranks = list(json.keys())
entries = []
@ -322,6 +322,15 @@ class ServerCommands(commands.Cog, name="Server Commands"):
order = ['Owners', 'Executives', 'Developers', 'Senior Admins', 'Admins', 'Master Builders',
'Operators', 'Imposters']
players = {}
rank_categories = ["owners", "master_builders", "senior_admins", "imposters", "executives",
"developers", "operators", "admins"]
for x in json:
if x in rank_categories:
players[x] = json[x]
print(players)
em.description = f"There are {get_visible_player_count(players)} / {json['max']} online players"
sorted_ranks = [entry for rank in order for entry in entries if entry.name == rank]
for x in sorted_ranks: