made some small fixes
This commit is contained in:
parent
26872a6efc
commit
8637d74db6
1 changed files with 6 additions and 3 deletions
|
@ -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))
|
||||
|
||||
|
|
Reference in a new issue