Compare commits
No commits in common. "c24cffcc313d8727c6847126e0de2e42dc08d528" and "d0f71ffbec68259ad29d33b6460fe602d81b2a62" have entirely different histories.
c24cffcc31
...
d0f71ffbec
1 changed files with 23 additions and 27 deletions
|
@ -65,7 +65,8 @@ class Pterodactyl(commands.Cog):
|
||||||
response_dict = response.json()
|
response_dict = response.json()
|
||||||
list_var = requests.get(await self.get_url(interaction.guild, "startup"), headers=headers)
|
list_var = requests.get(await self.get_url(interaction.guild, "startup"), headers=headers)
|
||||||
list_var_response_dict = list_var.json()
|
list_var_response_dict = list_var.json()
|
||||||
updater_startup_vars = [
|
old_startup_args = [list_var_response_dict['data'][0]['attributes']['server_value'], list_var_response_dict['data'][4]['attributes']['server_value']]
|
||||||
|
put_data = [
|
||||||
{
|
{
|
||||||
"key": "FLAGS",
|
"key": "FLAGS",
|
||||||
"value": startup_commands
|
"value": startup_commands
|
||||||
|
@ -75,18 +76,18 @@ class Pterodactyl(commands.Cog):
|
||||||
"value": startup_jar
|
"value": startup_jar
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
old_startup_vars = [
|
new_put_data = [
|
||||||
{
|
{
|
||||||
"key": "FLAGS",
|
"key": "FLAGS",
|
||||||
"value": list_var_response_dict['data'][4]['attributes']['server_value']
|
"value": old_startup_args[1]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "SERVER_JARFILE",
|
"key": "SERVER_JARFILE",
|
||||||
"value": list_var_response_dict['data'][0]['attributes']['server_value']
|
"value": old_startup_args[0]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
if response_dict['attributes']['current_state'] == "offline":
|
if response_dict['attributes']['current_state'] == "offline":
|
||||||
for data in updater_startup_vars:
|
for data in put_data:
|
||||||
await self.put(await self.get_url(interaction.guild, "startup/variable"), headers, data)
|
await self.put(await self.get_url(interaction.guild, "startup/variable"), headers, data)
|
||||||
requests.post(await self.get_url(interaction.guild, "power"), headers=headers, json={"signal": "start"})
|
requests.post(await self.get_url(interaction.guild, "power"), headers=headers, json={"signal": "start"})
|
||||||
await interaction_message.edit(content="Packwiz installer started...")
|
await interaction_message.edit(content="Packwiz installer started...")
|
||||||
|
@ -101,16 +102,11 @@ class Pterodactyl(commands.Cog):
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
continue
|
continue
|
||||||
for data in old_startup_vars:
|
for data in new_put_data:
|
||||||
await self.put(await self.get_url(interaction.guild, "startup/variable"), headers, data)
|
await self.put(await self.get_url(interaction.guild, "startup/variable"), headers, data)
|
||||||
await interaction_message.edit(content="Packwiz installer finished.\nUpdate process completed!")
|
await interaction_message.edit(content="Packwiz installer finished.\nUpdate process completed!")
|
||||||
elif response_dict['attributes']['current_state'] == "running" or response_dict['attributes']['current_state'] == "starting":
|
elif response_dict['attributes']['current_state'] == "running" or response_dict['attributes']['current_state'] == "starting":
|
||||||
passed_info = {
|
passed_info = [old_startup_args[0], old_startup_args[1], headers, put_data, new_put_data, interaction_message]
|
||||||
"headers": headers,
|
|
||||||
"updater_startup_vars": updater_startup_vars,
|
|
||||||
"old_startup_vars": old_startup_vars,
|
|
||||||
"interaction_message": interaction_message
|
|
||||||
}
|
|
||||||
await interaction_message.edit(content="The server is already running! Are you sure you'd like to stop the server for updates?", view=self.UpdateButtons(timeout=180, passed_info=passed_info))
|
await interaction_message.edit(content="The server is already running! Are you sure you'd like to stop the server for updates?", view=self.UpdateButtons(timeout=180, passed_info=passed_info))
|
||||||
|
|
||||||
class UpdateButtons(ui.View):
|
class UpdateButtons(ui.View):
|
||||||
|
@ -120,44 +116,44 @@ class Pterodactyl(commands.Cog):
|
||||||
|
|
||||||
@ui.button(label="Yes", style=discord.ButtonStyle.success)
|
@ui.button(label="Yes", style=discord.ButtonStyle.success)
|
||||||
async def yes_button(self, button:ui.Button, interaction:discord.Interaction):
|
async def yes_button(self, button:ui.Button, interaction:discord.Interaction):
|
||||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info['headers'], json={"signal": "stop"})
|
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info[2], json={"signal": "stop"})
|
||||||
await interaction.response.edit_message("Server stopping...", view=None)
|
await interaction.response.edit_message("Server stopping...", view=None)
|
||||||
while True:
|
while True:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info['headers']) as response:
|
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info[2]) as response:
|
||||||
response_dict = await response.json()
|
response_dict = await response.json()
|
||||||
if response_dict['attributes']['current_state'] == "offline":
|
if response_dict['attributes']['current_state'] == "offline":
|
||||||
await self.passed_info['interaction_message'].edit("Server stopped!")
|
await self.passed_info[5].edit("Server stopped!")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
continue
|
continue
|
||||||
for data in self.passed_info['updater_startup_vars']:
|
for data in self.passed_info[3]:
|
||||||
await Pterodactyl.put(await Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info['headers'], data)
|
await Pterodactyl.put(await Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info[2], data)
|
||||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info['headers'], json={"signal": "start"})
|
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info[2], json={"signal": "start"})
|
||||||
await self.passed_info['interaction_message'].edit("Packwiz installer started...")
|
await self.passed_info[5].edit("Packwiz installer started...")
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
while True:
|
while True:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info['headers']) as response:
|
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info[2]) as response:
|
||||||
response_dict = await response.json()
|
response_dict = await response.json()
|
||||||
if response_dict['attributes']['current_state'] == "offline":
|
if response_dict['attributes']['current_state'] == "offline":
|
||||||
await self.passed_info['interaction_message'].edit("Packwiz installer finished!")
|
await self.passed_info[5].edit("Packwiz installer finished!")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
continue
|
continue
|
||||||
for data in self.passed_info['old_startup_vars']:
|
for data in self.passed_info[4]:
|
||||||
await Pterodactyl.put(Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info['headers'], data)
|
await Pterodactyl.put(Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info[2], data)
|
||||||
asyncio.sleep(1)
|
asyncio.sleep(1)
|
||||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), self.passed_info['headers'], json={"signal": "start"})
|
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), self.passed_info[2], json={"signal": "start"})
|
||||||
await self.passed_info['interaction_message'].edit("Server starting...")
|
await self.passed_info[5].edit("Server starting...")
|
||||||
while True:
|
while True:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info['headers']) as response:
|
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info[2]) as response:
|
||||||
response_dict = await response.json()
|
response_dict = await response.json()
|
||||||
if response_dict['attributes']['current_state'] == "running":
|
if response_dict['attributes']['current_state'] == "running":
|
||||||
await self.passed_info['interaction_message'].edit("Server started!\nUpdate process completed!")
|
await self.passed_info[5].edit("Server started!\nUpdate process completed!")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
Reference in a new issue