feat(pterodactyl): added confirmation prompts to the power commands
This commit is contained in:
parent
093a6b9077
commit
b2f27f9490
1 changed files with 27 additions and 9 deletions
|
@ -122,9 +122,15 @@ class Pterodactyl(commands.Cog):
|
||||||
return await ctx.send("Server is already running.")
|
return await ctx.send("Server is already running.")
|
||||||
if current_status in ["starting", "stopping"]:
|
if current_status in ["starting", "stopping"]:
|
||||||
return await ctx.send("Another power action is already in progress.")
|
return await ctx.send("Another power action is already in progress.")
|
||||||
message = await ctx.send("Sending websocket command to start server...")
|
view = ConfirmView(ctx.author, disable_buttons=True)
|
||||||
await self.websocket.send(json.dumps({"event": "set state", "args": ["start"]}))
|
message = await ctx.send("Are you sure you want to start the server?", view=view)
|
||||||
await message.edit(content="Server starting...")
|
await view.wait()
|
||||||
|
if view.result is True:
|
||||||
|
await ctx.message("Sending websocket command to start server...")
|
||||||
|
await self.websocket.send(json.dumps({"event": "set state", "args": ["start"]}))
|
||||||
|
await message.edit(content="Server starting...")
|
||||||
|
else:
|
||||||
|
await message.edit(content="Cancelled.")
|
||||||
|
|
||||||
@pterodactyl_power.command(name = "stop")
|
@pterodactyl_power.command(name = "stop")
|
||||||
async def pterodactyl_power_stop(self, ctx: commands.Context) -> None:
|
async def pterodactyl_power_stop(self, ctx: commands.Context) -> None:
|
||||||
|
@ -134,9 +140,15 @@ class Pterodactyl(commands.Cog):
|
||||||
return await ctx.send("Server is already stopped.")
|
return await ctx.send("Server is already stopped.")
|
||||||
if current_status in ["starting", "stopping"]:
|
if current_status in ["starting", "stopping"]:
|
||||||
return await ctx.send("Another power action is already in progress.")
|
return await ctx.send("Another power action is already in progress.")
|
||||||
message = await ctx.send("Sending websocket command to stop server...")
|
view = ConfirmView(ctx.author, disable_buttons=True)
|
||||||
await self.websocket.send(json.dumps({"event": "set state", "args": ["stop"]}))
|
message = await ctx.send("Are you sure you want to stop the server?", view=view)
|
||||||
await message.edit(content="Server stopping...")
|
await view.wait()
|
||||||
|
if view.result is True:
|
||||||
|
await message.edit("Sending websocket command to stop server...")
|
||||||
|
await self.websocket.send(json.dumps({"event": "set state", "args": ["stop"]}))
|
||||||
|
await message.edit(content="Server stopping...")
|
||||||
|
else:
|
||||||
|
await message.edit(content="Cancelled.")
|
||||||
|
|
||||||
@pterodactyl_power.command(name = "restart")
|
@pterodactyl_power.command(name = "restart")
|
||||||
async def pterodactyl_power_restart(self, ctx: commands.Context) -> None:
|
async def pterodactyl_power_restart(self, ctx: commands.Context) -> None:
|
||||||
|
@ -144,9 +156,15 @@ class Pterodactyl(commands.Cog):
|
||||||
current_status = await config.current_status()
|
current_status = await config.current_status()
|
||||||
if current_status in ["starting", "stopping"]:
|
if current_status in ["starting", "stopping"]:
|
||||||
return await ctx.send("Another power action is already in progress.")
|
return await ctx.send("Another power action is already in progress.")
|
||||||
message = await ctx.send("Sending websocket command to restart server...")
|
view = ConfirmView(ctx.author, disable_buttons=True)
|
||||||
await self.websocket.send(json.dumps({"event": "set state", "args": ["restart"]}))
|
message = await ctx.send("Are you sure you want to restart the server?", view=view)
|
||||||
await message.edit(content="Server restarting...")
|
await view.wait()
|
||||||
|
if view.result is True:
|
||||||
|
await message.edit("Sending websocket command to restart server...")
|
||||||
|
await self.websocket.send(json.dumps({"event": "set state", "args": ["restart"]}))
|
||||||
|
await message.edit(content="Server restarting...")
|
||||||
|
else:
|
||||||
|
await message.edit(content="Cancelled.")
|
||||||
|
|
||||||
@pterodactyl.group(autohelp = True, name = "config", aliases = ["settings", "set"])
|
@pterodactyl.group(autohelp = True, name = "config", aliases = ["settings", "set"])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
|
|
Loading…
Reference in a new issue