forked from cswimr/SeaCogs
feat(pterodactyl): add power commands
This commit is contained in:
parent
b75bacb811
commit
6a02381e89
1 changed files with 39 additions and 0 deletions
|
@ -107,6 +107,45 @@ class Pterodactyl(commands.Cog):
|
|||
async def pterodactyl(self, ctx: commands.Context) -> None:
|
||||
"""Pterodactyl allows you to manage your Pterodactyl Panel from Discord."""
|
||||
|
||||
@pterodactyl.group(autohelp = True, name = "power")
|
||||
@commands.admin()
|
||||
async def pterodactyl_power(self, ctx: commands.Context) -> None:
|
||||
"""Send power actions to the server."""
|
||||
|
||||
@pterodactyl_power.command(name = "start")
|
||||
async def pterodactyl_power_start(self, ctx: commands.Context) -> None:
|
||||
"""Start the server."""
|
||||
current_status = await config.current_status()
|
||||
if current_status == "running":
|
||||
return await ctx.send("Server is already running.")
|
||||
elif current_status in ["starting", "stopping"]:
|
||||
return await ctx.send("Another power action is already in progress.")
|
||||
message = await ctx.send("Sending websocket command to start server...")
|
||||
await self.websocket.send(json.dumps({"event": "set state", "args": ["start"]}))
|
||||
await message.edit(content="Server starting...")
|
||||
|
||||
@pterodactyl_power.command(name = "stop")
|
||||
async def pterodactyl_power_stop(self, ctx: commands.Context) -> None:
|
||||
"""Stop the server."""
|
||||
current_status = await config.current_status()
|
||||
if current_status == "stopped":
|
||||
return await ctx.send("Server is already stopped.")
|
||||
elif current_status in ["starting", "stopping"]:
|
||||
return await ctx.send("Another power action is already in progress.")
|
||||
message = await ctx.send("Sending websocket command to stop server...")
|
||||
await self.websocket.send(json.dumps({"event": "set state", "args": ["stop"]}))
|
||||
await message.edit(content="Server stopping...")
|
||||
|
||||
@pterodactyl_power.command(name = "restart")
|
||||
async def pterodactyl_power_restart(self, ctx: commands.Context) -> None:
|
||||
"""Restart the server."""
|
||||
current_status = await config.current_status()
|
||||
if current_status in ["starting", "stopping"]:
|
||||
return await ctx.send("Another power action is already in progress.")
|
||||
message = await ctx.send("Sending websocket command to restart server...")
|
||||
await self.websocket.send(json.dumps({"event": "set state", "args": ["restart"]}))
|
||||
await message.edit(content="Server restarting...")
|
||||
|
||||
@pterodactyl.group(autohelp = True, name = "config", aliases = ["settings", "set"])
|
||||
@commands.is_owner()
|
||||
async def pterodactyl_config(self, ctx: commands.Context) -> None:
|
||||
|
|
Loading…
Reference in a new issue