fix: fixed starting updater while server is online
This commit is contained in:
parent
52ebccc1d9
commit
b2ba7f165d
1 changed files with 21 additions and 8 deletions
|
@ -120,11 +120,11 @@ 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(self.passed_info['interaction'].guild, "power"), headers=self.passed_info['headers'], json={"signal": "stop"})
|
requests.post(await Pterodactyl.get_url(self, interaction.guild, "power"), headers=self.passed_info['headers'], json={"signal": "stop"})
|
||||||
await self.passed_info['interaction'].edit_original_response("Server stopping...", view=None)
|
await self.passed_info['interaction'].edit_original_response("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(self, interaction.guild, "resources"), headers=self.passed_info['headers']) 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'].edit_original_response("\nServer stopped!")
|
await self.passed_info['interaction'].edit_original_response("\nServer stopped!")
|
||||||
|
@ -133,13 +133,13 @@ class Pterodactyl(commands.Cog):
|
||||||
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['updater_startup_vars']:
|
||||||
await Pterodactyl.put(await Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info['headers'], data)
|
await Pterodactyl.put(await Pterodactyl.get_url(self, interaction.guild, "startup/variable"), self.passed_info['headers'], data)
|
||||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info['headers'], json={"signal": "start"})
|
requests.post(await Pterodactyl.get_url(self, interaction.guild, "power"), headers=self.passed_info['headers'], json={"signal": "start"})
|
||||||
await self.passed_info['interaction'].edit_original_response("Packwiz installer started...")
|
await self.passed_info['interaction'].edit_original_response("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(self, interaction.guild, "resources"), headers=self.passed_info['headers']) 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'].edit_original_response("Packwiz installer finished!")
|
await self.passed_info['interaction'].edit_original_response("Packwiz installer finished!")
|
||||||
|
@ -148,13 +148,13 @@ class Pterodactyl(commands.Cog):
|
||||||
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['old_startup_vars']:
|
||||||
await Pterodactyl.put(Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info['headers'], data)
|
await Pterodactyl.put(Pterodactyl.get_url(self, interaction.guild, "startup/variable"), self.passed_info['headers'], 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(self, interaction.guild, "power"), self.passed_info['headers'], json={"signal": "start"})
|
||||||
await self.passed_info['interaction'].edit_original_response("Server starting...")
|
await self.passed_info['interaction'].edit_original_response("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(self, interaction.guild, "resources"), headers=self.passed_info['headers']) 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'].edit_original_response("Server started!\nUpdate process completed!")
|
await self.passed_info['interaction'].edit_original_response("Server started!\nUpdate process completed!")
|
||||||
|
@ -270,3 +270,16 @@ class Pterodactyl(commands.Cog):
|
||||||
else:
|
else:
|
||||||
send = f"Configuration changed:\n{message}"
|
send = f"Configuration changed:\n{message}"
|
||||||
await interaction.response.send_message(send, ephemeral=True)
|
await interaction.response.send_message(send, ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Authorization": "Bearer ptlc_12FrmCqnbe1jdtE6AB1np4xL4xsNLl4b8FJVPE0dMWv",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post("https://mc.bloom.host/api/client/servers/d6d05b41-4da5-4c5b-9ee6-6e25f61a596b/power", headers=headers, json={"signal": "stop"})
|
||||||
|
response_json = response.json()
|
||||||
|
print(response_json)
|
||||||
|
|
Reference in a new issue