fix: fixed power_action_in_progress

This commit is contained in:
Seaswimmer 2023-07-24 09:16:17 -04:00
parent 3ed6cffe5d
commit db764b54e2
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -102,7 +102,7 @@ class Pterodactyl(commands.Cog):
} }
] ]
if response_dict['attributes']['current_state'] == "offline": if response_dict['attributes']['current_state'] == "offline":
await self.config.guild(interaction.guild).power_action_in_progress().set(True) await self.config.guild(interaction.guild).power_action_in_progress.set(True)
for data in updater_startup_vars: for data in updater_startup_vars:
await session.put(await self.get_url(interaction.guild, "startup/variable"), headers=headers, json=data) await session.put(await self.get_url(interaction.guild, "startup/variable"), headers=headers, json=data)
await session.post(await self.get_url(interaction.guild, "power"), headers=headers, json={"signal": "start"}) await session.post(await self.get_url(interaction.guild, "power"), headers=headers, json={"signal": "start"})
@ -120,7 +120,7 @@ class Pterodactyl(commands.Cog):
for data in old_startup_vars: for data in old_startup_vars:
await session.put(await self.get_url(interaction.guild, "startup/variable"), headers=headers, json=data) await session.put(await self.get_url(interaction.guild, "startup/variable"), headers=headers, json=data)
await interaction_message.edit(content="Updater finished.\nUpdate process completed!") await interaction_message.edit(content="Updater finished.\nUpdate process completed!")
await self.config.guild(interaction.guild).power_action_in_progress().set(False) await self.config.guild(interaction.guild).power_action_in_progress.set(False)
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 = {
"headers": headers, "headers": headers,
@ -229,7 +229,7 @@ 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):
await self.config.guild(self.passed_info['guild']).power_action_in_progress().set(True) await self.config.guild(self.passed_info['guild']).power_action_in_progress.set(True)
session = self.session session = self.session
await session.post(await Pterodactyl.get_url(self, self.passed_info['guild'], "power"), headers=self.passed_info['headers'], json={"signal": "stop"}) await session.post(await Pterodactyl.get_url(self, self.passed_info['guild'], "power"), headers=self.passed_info['headers'], json={"signal": "stop"})
await self.passed_info['interaction'].edit_original_response(content="Server stopping...", view=None) await self.passed_info['interaction'].edit_original_response(content="Server stopping...", view=None)
@ -270,7 +270,7 @@ class Pterodactyl(commands.Cog):
else: else:
await asyncio.sleep(0.5) await asyncio.sleep(0.5)
continue continue
await self.config.guild(self.passed_info['guild']).power_action_in_progress().set(False) await self.config.guild(self.passed_info['guild']).power_action_in_progress.set(False)
@ui.button(label="No", style=discord.ButtonStyle.danger) @ui.button(label="No", style=discord.ButtonStyle.danger)
async def no_button(self, button:ui.Button, interaction:discord.Interaction): async def no_button(self, button:ui.Button, interaction:discord.Interaction):
@ -286,7 +286,7 @@ 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):
await self.config.guild(self.passed_info['guild']).power_action_in_progress().set(True) await self.config.guild(self.passed_info['guild']).power_action_in_progress.set(True)
headers = self.passed_info['headers'] headers = self.passed_info['headers']
await self.session.post(await Pterodactyl.get_url(self, self.passed_info['guild'], "power"), headers=headers, json={"signal": self.passed_info['signal']}) await self.session.post(await Pterodactyl.get_url(self, self.passed_info['guild'], "power"), headers=headers, json={"signal": self.passed_info['signal']})
message = await self.passed_info['interaction'].edit_original_response(content=self.passed_info['message'], view=None) message = await self.passed_info['interaction'].edit_original_response(content=self.passed_info['message'], view=None)
@ -299,7 +299,7 @@ class Pterodactyl(commands.Cog):
else: else:
await asyncio.sleep(1) await asyncio.sleep(1)
continue continue
await self.config.guild(self.passed_info['guild']).power_action_in_progress().set(False) await self.config.guild(self.passed_info['guild']).power_action_in_progress.set(False)
@ui.button(label="No", style=discord.ButtonStyle.danger) @ui.button(label="No", style=discord.ButtonStyle.danger)
async def no_button(self, button:ui.Button, interaction:discord.Interaction): async def no_button(self, button:ui.Button, interaction:discord.Interaction):