mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2024-12-22 15:44:57 +00:00
Update server_commands.py
This commit is contained in:
parent
66ff219d87
commit
c754a2b132
1 changed files with 17 additions and 37 deletions
|
@ -221,51 +221,31 @@ class ServerCommands(commands.Cog):
|
||||||
em = discord.Embed()
|
em = discord.Embed()
|
||||||
em.title = "Player List"
|
em.title = "Player List"
|
||||||
try:
|
try:
|
||||||
json = requests.get(
|
json = requests.get("http://play.totalfreedom.me:28966/list?json=true", timeout=5).json()
|
||||||
"http://play.totalfreedom.me:28966/list?json=true", timeout=5).json()
|
|
||||||
if json["online"] == 0:
|
if json["online"] == 0:
|
||||||
em.description = "There are no online players"
|
em.description = "There are no online players"
|
||||||
else:
|
else:
|
||||||
em.description = f"There are {json['online']} / {json['max']} online players"
|
em.description = f"There are {json['online']} / {json['max']} online players"
|
||||||
|
ranks = list(json.keys())
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
|
||||||
owners = json["owners"]
|
|
||||||
if len(owners) != 0:
|
|
||||||
em = format_list_entry(em, owners, "Server Owners")
|
|
||||||
executives = json["executives"]
|
|
||||||
if len(executives) != 0:
|
|
||||||
em = format_list_entry(em, executives, "Executives")
|
|
||||||
developers = json["developers"]
|
|
||||||
if len(developers) != 0:
|
|
||||||
em = format_list_entry(em, developers, "Developers")
|
|
||||||
senior_admins = json["senioradmins"]
|
|
||||||
if len(senior_admins) != 0:
|
|
||||||
em = format_list_entry(em, senior_admins, "Senior Admins")
|
|
||||||
admins = json["admins"]
|
|
||||||
if len(admins) != 0:
|
|
||||||
em = format_list_entry(em, admins, "Admins")
|
|
||||||
#trialadmins = json["trialadmins"]
|
|
||||||
#if len(trialadmins) != 0:
|
|
||||||
#em = format_list_entry(em, trialmods, "Trial Mods")
|
|
||||||
masterbuilders = json["masterbuilders"]
|
|
||||||
if len(masterbuilders) != 0:
|
|
||||||
em = format_list_entry(em, masterbuilders, "Master Builders")
|
|
||||||
operators = json["operators"]
|
|
||||||
if len(operators) != 0:
|
|
||||||
em = format_list_entry(em, operators, "Operators")
|
|
||||||
imposters = json["imposters"]
|
|
||||||
if len(imposters) != 0:
|
|
||||||
em = format_list_entry(em, imposters, "Imposters")
|
|
||||||
'''ranks = list(json.keys())
|
|
||||||
for rank in ranks:
|
for rank in ranks:
|
||||||
if rank not in ['max', 'online'] and json[rank]:
|
if rank not in ['max', 'online'] and json[rank]:
|
||||||
rank = rank.split('_')
|
rank_fixed = rank.split('_')
|
||||||
for word in range(len(rank)):
|
for word in range(len(rank_fixed)):
|
||||||
rank[word] = rank[word].capitalize()
|
rank_fixed[word] = rank_fixed[word].capitalize()
|
||||||
em = format_list_entry(
|
entries.append(format_list_entry(em, json[rank], f'{" ".join(rank_fixed)}'))
|
||||||
em, json[rank], f'{" ".join(rank)}')'''
|
|
||||||
|
|
||||||
except:
|
order = ['Owners', 'Executives', 'Developers', 'Senior Admins', 'Admins', 'Master Builders', 'Operators', 'Imposters']
|
||||||
|
sorted = [tpl for x in order for tpl in entries if tpl.name == x]
|
||||||
|
|
||||||
|
for x in sorted:
|
||||||
|
em.add_field(name=f'{x.name} ({x.playercount})', value=x.value, inline=False)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
em.description = 'Server is offline'
|
em.description = 'Server is offline'
|
||||||
|
print(e)
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
|
Loading…
Reference in a new issue