Compare commits

..

2 commits

Author SHA1 Message Date
8c58e1746e
feat(pterodactyl): added ptero power kill command
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 18s
Actions / Build Documentation (MkDocs) (push) Successful in 22s
2024-03-05 02:25:58 -05:00
52be531807
fix(pterodactyl): type hints 2024-03-05 02:24:20 -05:00

View file

@ -115,7 +115,7 @@ class Pterodactyl(commands.Cog):
"""Send power actions to the server."""
@pterodactyl_power.command(name = "start")
async def pterodactyl_power_start(self, ctx: commands.Context) -> None:
async def pterodactyl_power_start(self, ctx: commands.Context) -> Optional[discord.Message]:
"""Start the server."""
current_status = await config.current_status()
if current_status == "running":
@ -133,7 +133,7 @@ class Pterodactyl(commands.Cog):
await message.edit(content="Cancelled.", view=None)
@pterodactyl_power.command(name = "stop")
async def pterodactyl_power_stop(self, ctx: commands.Context) -> None:
async def pterodactyl_power_stop(self, ctx: commands.Context) -> Optional[discord.Message]:
"""Stop the server."""
current_status = await config.current_status()
if current_status == "stopped":
@ -151,7 +151,7 @@ class Pterodactyl(commands.Cog):
await message.edit(content="Cancelled.", view=None)
@pterodactyl_power.command(name = "restart")
async def pterodactyl_power_restart(self, ctx: commands.Context) -> None:
async def pterodactyl_power_restart(self, ctx: commands.Context) -> Optional[discord.Message]:
"""Restart the server."""
current_status = await config.current_status()
if current_status in ["starting", "stopping"]:
@ -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: