mirror of
https://github.com/opus-tango/minecraft-server-discord-bot.git
synced 2026-03-20 03:55:20 +00:00
add listplayers command
This commit is contained in:
10
bot.py
10
bot.py
@@ -427,6 +427,16 @@ async def list(ctx):
|
|||||||
listofservers = 'Available servers:\n' + "\n".join([('`' + s['servername'] + '` - ' + s['description']) for s in servers])
|
listofservers = 'Available servers:\n' + "\n".join([('`' + s['servername'] + '` - ' + s['description']) for s in servers])
|
||||||
await ctx.send(listofservers)
|
await ctx.send(listofservers)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
async def listplayers(ctx):
|
||||||
|
''' Lists the players in the server '''
|
||||||
|
global active_server
|
||||||
|
if active_server is None:
|
||||||
|
await ctx.send("No server is currently active.")
|
||||||
|
return
|
||||||
|
subprocess.Popen(f"screen -S {active_server} -p 0 -X stuff 'list\n'", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
|
await ctx.send("Please wait, listing players may take a second...")
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def forcestopserver(ctx):
|
async def forcestopserver(ctx):
|
||||||
''' Force stop the server by sending keyboard interrupt (admin only) '''
|
''' Force stop the server by sending keyboard interrupt (admin only) '''
|
||||||
|
|||||||
Reference in New Issue
Block a user