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
da81f4ad37
commit
b762622bd2
1 changed files with 42 additions and 38 deletions
|
@ -138,7 +138,8 @@ class ServerCommands(commands.Cog):
|
||||||
for arg in args:
|
for arg in args:
|
||||||
command += f'{arg} '
|
command += f'{arg} '
|
||||||
try:
|
try:
|
||||||
if args[0] in ['mute', 'stfu', 'gtfo', 'ban', 'unban', 'unmute', 'smite', 'noob', 'tban', 'tempban', 'warn', 'mv', 'kick', 'cc', 'say']:
|
if args[0] in ['mute', 'stfu', 'gtfo', 'ban', 'unban', 'unmute', 'smite', 'noob', 'tban', 'tempban', 'warn',
|
||||||
|
'mv', 'kick', 'cc', 'say']:
|
||||||
self.write_telnet_session(server,
|
self.write_telnet_session(server,
|
||||||
bytes(command, 'ascii') + b"\r\n")
|
bytes(command, 'ascii') + b"\r\n")
|
||||||
elif args[0] == 'saconfig':
|
elif args[0] == 'saconfig':
|
||||||
|
@ -249,7 +250,7 @@ class ServerCommands(commands.Cog):
|
||||||
em.colour = 0xFF0000
|
em.colour = 0xFF0000
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
@commands.command(name='list', aliases=['l','who','lsit'])
|
@commands.command(name='list', aliases=['l', 'who', 'lsit'])
|
||||||
async def online(self, ctx):
|
async def online(self, ctx):
|
||||||
"""Gives a list of online players."""
|
"""Gives a list of online players."""
|
||||||
em = discord.Embed()
|
em = discord.Embed()
|
||||||
|
@ -277,7 +278,8 @@ class ServerCommands(commands.Cog):
|
||||||
rank_fixed[word] = rank_fixed[word].capitalize()
|
rank_fixed[word] = rank_fixed[word].capitalize()
|
||||||
entries.append(format_list_entry(em, json[rank], f'{" ".join(rank_fixed)}'))
|
entries.append(format_list_entry(em, json[rank], f'{" ".join(rank_fixed)}'))
|
||||||
|
|
||||||
order = ['Owners', 'Executives', 'Developers', 'Senior Admins', 'Admins', 'Master Builders', 'Operators', 'Imposters']
|
order = ['Owners', 'Executives', 'Developers', 'Senior Admins', 'Admins', 'Master Builders',
|
||||||
|
'Operators', 'Imposters']
|
||||||
sorted = [entry for rank in order for entry in entries if entry.name == rank]
|
sorted = [entry for rank in order for entry in entries if entry.name == rank]
|
||||||
|
|
||||||
for x in sorted:
|
for x in sorted:
|
||||||
|
@ -346,10 +348,12 @@ class ServerCommands(commands.Cog):
|
||||||
allocated_memory = allocated_memory.strip(':Free memory:')
|
allocated_memory = allocated_memory.strip(':Free memory:')
|
||||||
free_memory = free_memory.strip(':World "world":')
|
free_memory = free_memory.strip(':World "world":')
|
||||||
|
|
||||||
print(f'TPS: {server_tps} UPTIME: {server_uptime} MAX MEM: {maximum_memory} ALLCTD MEM: {allocated_memory} FREE MEM: {free_memory}')
|
print(
|
||||||
|
f'TPS: {server_tps} UPTIME: {server_uptime} MAX MEM: {maximum_memory} ALLCTD MEM: {allocated_memory} FREE MEM: {free_memory}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server_uptime = re.match('([0-9]+ days? )?([0-9]+ hours )?([0-9]+ minutes )?([0-6]?[0-9] seconds)', server_uptime)[0]
|
server_uptime = \
|
||||||
|
re.match('([0-9]+ days? )?([0-9]+ hours )?([0-9]+ minutes )?([0-6]?[0-9] seconds)', server_uptime)[0]
|
||||||
server_tps = re.match('[0-2][0-9].?[0-9]*', server_tps)[0]
|
server_tps = re.match('[0-2][0-9].?[0-9]*', server_tps)[0]
|
||||||
maximum_memory = re.match('[0-9]+,?[0-9]* MB', maximum_memory)[0]
|
maximum_memory = re.match('[0-9]+,?[0-9]* MB', maximum_memory)[0]
|
||||||
allocated_memory = re.match('[0-9]+,?[0-9]* MB', allocated_memory)[0]
|
allocated_memory = re.match('[0-9]+,?[0-9]* MB', allocated_memory)[0]
|
||||||
|
@ -358,11 +362,11 @@ class ServerCommands(commands.Cog):
|
||||||
em.description = f'Something went wrong: {e}'
|
em.description = f'Something went wrong: {e}'
|
||||||
em.colour = 0xFF0000
|
em.colour = 0xFF0000
|
||||||
else:
|
else:
|
||||||
em.add_field(name='TPS', value = server_tps, inline=False)
|
em.add_field(name='TPS', value=server_tps, inline=False)
|
||||||
em.add_field(name='Uptime', value = server_uptime, inline=False)
|
em.add_field(name='Uptime', value=server_uptime, inline=False)
|
||||||
em.add_field(name='Maximum Memory', value = maximum_memory, inline=False)
|
em.add_field(name='Maximum Memory', value=maximum_memory, inline=False)
|
||||||
em.add_field(name='Allocated Memory', value = allocated_memory, inline=False)
|
em.add_field(name='Allocated Memory', value=allocated_memory, inline=False)
|
||||||
em.add_field(name='Free Memory', value = free_memory, inline=False)
|
em.add_field(name='Free Memory', value=free_memory, inline=False)
|
||||||
else:
|
else:
|
||||||
em.description = 'Server is offline'
|
em.description = 'Server is offline'
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
Loading…
Reference in a new issue