From 8c58e1746e701ad0f7419fd15b26199f84f1e8b2 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Tue, 5 Mar 2024 02:25:58 -0500 Subject: [PATCH] feat(pterodactyl): added ptero power kill command --- pterodactyl/pterodactyl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pterodactyl/pterodactyl.py b/pterodactyl/pterodactyl.py index baa9724..9855806 100644 --- a/pterodactyl/pterodactyl.py +++ b/pterodactyl/pterodactyl.py @@ -166,6 +166,22 @@ class Pterodactyl(commands.Cog): else: await message.edit(content="Cancelled.", view=None) + @pterodactyl_power.command(name = "kill") + async def pterodactyl_power_kill(self, ctx: commands.Context) -> Optional[discord.Message]: + """Kill the server.""" + current_status = await config.current_status() + if current_status == 'stopped': + return await ctx.send("Server is already stopped.") + view = ConfirmView(ctx.author, disable_buttons=True) + message = await ctx.send("**⚠️ Forcefully killing the server process can corrupt data in some cases.**\nAre you sure you want to kill the server?", view=view) + await view.wait() + if view.result is True: + await message.edit(content="Sending websocket command to kill server...", view=None) + await self.websocket.send(json.dumps({"event": "set state", "args": ["kill"]})) + await message.edit(content="Server stopping... (forcefully killed)", view=None) + else: + await message.edit(content="Cancelled.", view=None) + @pterodactyl.group(autohelp = True, name = "config", aliases = ["settings", "set"]) @commands.is_owner() async def pterodactyl_config(self, ctx: commands.Context) -> None: