From 8637d74db6b13b2e8d9d2139ed84a2790ca6299e Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 15 Jul 2023 17:42:16 -0400 Subject: [PATCH] made some small fixes --- pterodactyl/ptero.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pterodactyl/ptero.py b/pterodactyl/ptero.py index b4d71a2..1af47de 100644 --- a/pterodactyl/ptero.py +++ b/pterodactyl/ptero.py @@ -40,10 +40,13 @@ class Pterodactyl(commands.Cog): @app_commands.command() async def update(self, interaction: discord.Interaction): if await self.config.guild(interaction.guild).api_key() is None: + await interaction.response.send_message(f"Something went wrong.\nError: `API Key not set.`", ephemeral=True) raise LookupError("API Key not set.") elif await self.config.guild(interaction.guild).startup_jar() is None: + await interaction.response.send_message(f"Something went wrong.\nError: `Startup jar not set.`", ephemeral=True) raise LookupError("Startup jar not set.") elif await self.config.guild(interaction.guild).startup_arguments() is None: + await interaction.response.send_message(f"Something went wrong.\nError: `Startup arguments not set.`", ephemeral=True) raise LookupError("Startup arguments not set.") else: api_key = await self.config.guild(interaction.guild).api_key() @@ -83,20 +86,20 @@ class Pterodactyl(commands.Cog): } ] requests.post(await self.get_url(interaction.guild, "power"), headers=headers, json={"signal": "start"}) - await interaction.response.send_message("Packwiz installer started...", ephemeral=True) + interaction_response = await interaction.response.send_message(content="Packwiz installer started...", ephemeral=True) while True: async with aiohttp.ClientSession() as session: async with session.get(await self.get_url(interaction.guild, "resources"), headers=headers) as response: response_dict = await response.json() if response_dict['attributes']['current_state'] == "offline": - await interaction.original_response.edit("Packwiz installer finished!") + await interaction_response.edit("Packwiz installer finished!") break else: await asyncio.sleep(1) continue for data in new_put_data: await self.put(await self.get_url(interaction.guild, "startup/variable"), headers, data) - elif response_dict['attributes']['current_state'] == "running": + elif response_dict['attributes']['current_state'] == "running" or response_dict['attributes']['current_state'] == "starting": passed_info = [old_startup_args[0], old_startup_args[1], headers, put_data, new_put_data] await interaction.response.send_message("Server is already running! Are you sure you'd like to stop the server for updates?", ephemeral=True, view=self.UpdateButtons(timeout=180, passed_info=passed_info))