diff --git a/pterodactyl/ptero.py b/pterodactyl/ptero.py index c39435c..e934273 100644 --- a/pterodactyl/ptero.py +++ b/pterodactyl/ptero.py @@ -120,11 +120,11 @@ 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(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) 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: + async with session.get(await Pterodactyl.get_url(self, 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'].edit_original_response("\nServer stopped!") @@ -133,13 +133,13 @@ class Pterodactyl(commands.Cog): await asyncio.sleep(2) continue 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 Pterodactyl.put(await Pterodactyl.get_url(self, interaction.guild, "startup/variable"), self.passed_info['headers'], data) + 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 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: + async with session.get(await Pterodactyl.get_url(self, 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'].edit_original_response("Packwiz installer finished!") @@ -148,13 +148,13 @@ class Pterodactyl(commands.Cog): await asyncio.sleep(1) continue 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) - 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...") 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: + async with session.get(await Pterodactyl.get_url(self, 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'].edit_original_response("Server started!\nUpdate process completed!") @@ -270,3 +270,16 @@ class Pterodactyl(commands.Cog): else: send = f"Configuration changed:\n{message}" 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)