feat: made the cancelled update command autodelete after 5 seconds
This commit is contained in:
parent
b5f081d479
commit
09b7a4a6ab
1 changed files with 8 additions and 9 deletions
|
@ -121,13 +121,13 @@ class Pterodactyl(commands.Cog):
|
|||
@ui.button(label="Yes", style=discord.ButtonStyle.success)
|
||||
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"})
|
||||
await interaction.edit_original_response("Server stopping...", view=None)
|
||||
await self.passed_info['interaction'].edit_original_response("Server stopping...", view=None)
|
||||
while True:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info['headers']) as response:
|
||||
response_dict = await response.json()
|
||||
if response_dict['attributes']['current_state'] == "offline":
|
||||
await self.passed_info['interaction_message'].edit("Server stopped!")
|
||||
await self.passed_info['interaction'].edit_original_response("Server stopped!")
|
||||
break
|
||||
else:
|
||||
await asyncio.sleep(2)
|
||||
|
@ -135,14 +135,14 @@ class Pterodactyl(commands.Cog):
|
|||
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)
|
||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info['headers'], json={"signal": "start"})
|
||||
await self.passed_info['interaction_message'].edit("Packwiz installer started...")
|
||||
await self.passed_info['interaction'].edit_original_response("Packwiz installer started...")
|
||||
await asyncio.sleep(1)
|
||||
while True:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info['headers']) as response:
|
||||
response_dict = await response.json()
|
||||
if response_dict['attributes']['current_state'] == "offline":
|
||||
await self.passed_info['interaction_message'].edit("Packwiz installer finished!")
|
||||
await self.passed_info['interaction'].edit_original_response("Packwiz installer finished!")
|
||||
break
|
||||
else:
|
||||
await asyncio.sleep(1)
|
||||
|
@ -151,13 +151,13 @@ class Pterodactyl(commands.Cog):
|
|||
await Pterodactyl.put(Pterodactyl.get_url(interaction.guild, "startup/variable"), self.passed_info['headers'], data)
|
||||
asyncio.sleep(1)
|
||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), self.passed_info['headers'], json={"signal": "start"})
|
||||
await self.passed_info['interaction_message'].edit("Server starting...")
|
||||
await self.passed_info['interaction'].edit_original_response("Server starting...")
|
||||
while True:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(await Pterodactyl.get_url(interaction.guild, "resources"), headers=self.passed_info['headers']) as response:
|
||||
response_dict = await response.json()
|
||||
if response_dict['attributes']['current_state'] == "running":
|
||||
await self.passed_info['interaction_message'].edit("Server started!\nUpdate process completed!")
|
||||
await self.passed_info['interaction'].edit_original_response("Server started!\nUpdate process completed!")
|
||||
break
|
||||
else:
|
||||
await asyncio.sleep(1)
|
||||
|
@ -165,9 +165,8 @@ class Pterodactyl(commands.Cog):
|
|||
|
||||
@ui.button(label="No", style=discord.ButtonStyle.danger)
|
||||
async def no_button(self, button:ui.Button, interaction:discord.Interaction):
|
||||
for button in self.children:
|
||||
button.disabled = True
|
||||
await self.passed_info['interaction'].edit_original_response(content=f"Command cancelled.", view=self)
|
||||
message = await self.passed_info['interaction'].edit_original_response(content=f"Command cancelled.", view=None)
|
||||
await message.delete(delay=5)
|
||||
|
||||
@app_commands.command()
|
||||
async def test(self, interaction: discord.Interaction, endpoint: str = None):
|
||||
|
|
Reference in a new issue