fix: fixed power and update commands' error checking

This commit is contained in:
Seaswimmer 2023-07-24 09:04:58 -04:00
parent 20a6d89f3d
commit dcd3560fbc
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -57,7 +57,7 @@ class Pterodactyl(commands.Cog):
@app_commands.guild_only()
async def update(self, interaction: discord.Interaction):
"""Updates the server using the arguments provided in the server's configuration."""
if await self.config.guild(self.passed_info['guild']).power_action_in_progress() is True:
if await self.config.guild(interaction.guild).power_action_in_progress() is True:
await interaction.response.send_message(ephemeral=True, content="Power action already in progress!\nTry again later.")
return
session = self.session
@ -102,7 +102,7 @@ class Pterodactyl(commands.Cog):
}
]
if response_dict['attributes']['current_state'] == "offline":
await self.config.guild(self.passed_info['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:
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"})
@ -120,7 +120,7 @@ class Pterodactyl(commands.Cog):
for data in old_startup_vars:
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 self.config.guild(self.passed_info['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":
passed_info = {
"headers": headers,
@ -137,7 +137,7 @@ class Pterodactyl(commands.Cog):
@app_commands.guild_only()
async def start(self, interaction: discord.Interaction):
"""Starts the server."""
if await self.config.guild(self.passed_info['guild']).power_action_in_progress() is True:
if await self.config.guild(interaction.guild).power_action_in_progress() is True:
await interaction.response.send_message(ephemeral=True, content="Power action already in progress!\nTry again later.")
return
await interaction.response.defer(ephemeral=True, thinking=True)
@ -165,7 +165,7 @@ class Pterodactyl(commands.Cog):
@app_commands.guild_only()
async def restart(self, interaction: discord.Interaction):
"""Restarts the server."""
if await self.config.guild(self.passed_info['guild']).power_action_in_progress() is True:
if await self.config.guild(interaction.guild).power_action_in_progress() is True:
await interaction.response.send_message(ephemeral=True, content="Power action already in progress!\nTry again later.")
return
await interaction.response.defer(ephemeral=True, thinking=True)
@ -196,7 +196,7 @@ class Pterodactyl(commands.Cog):
@app_commands.guild_only()
async def stop(self, interaction: discord.Interaction):
"""Stops the server."""
if await self.config.guild(self.passed_info['guild']).power_action_in_progress() is True:
if await self.config.guild(interaction.guild).power_action_in_progress() is True:
await interaction.response.send_message(ephemeral=True, content="Power action already in progress!\nTry again later.")
return
await interaction.response.defer(ephemeral=True, thinking=True)