Compare commits

..

No commits in common. "2f8146d4f47db298f838f174fe4f9421cd67cfe3" and "55067cb26935950a05e077f75948958ec460601a" have entirely different histories.

View file

@ -3,7 +3,6 @@ import aiohttp
import discord
import requests
from discord import ui
from discord.ext import commands
from redbot.core import commands, app_commands, Config
class Pterodactyl(commands.Cog):
@ -21,16 +20,16 @@ class Pterodactyl(commands.Cog):
)
async def get_url(self, guild, endpoint = None):
"""Returns the base url for the server's API, or the url for a specific API endpoint if one is provided."""
"""Returns the base url for the Servers API, or the url for a specific API endpoint if one is provided."""
if await self.config.guild(guild).server_id() is None:
raise LookupError("Server ID not set.")
elif await self.config.guild(guild).base_url() is None:
raise LookupError("Base URL not set.")
base_url = await self.config.guild(guild).base_url()
server_id = await self.config.guild(guild).server_id()
url = f"https://{base_url}/api/client/servers/{server_id}"
url = f"https://{base_url}/api/client/servers/{server_id}/"
if endpoint:
url += '/' + endpoint
url += endpoint
return url
async def put(self, url: str, headers: dict, data: dict):
@ -110,8 +109,7 @@ class Pterodactyl(commands.Cog):
"headers": headers,
"updater_startup_vars": updater_startup_vars,
"old_startup_vars": old_startup_vars,
"interaction": interaction,
"interaction_context": await commands.Context.from_interaction(interaction),
"interaction": interaction
}
await interaction_message.edit(content="The server is already running! Are you sure you'd like to stop the server for updates?", view=self.UpdateButtons(timeout=180, passed_info=passed_info))
@ -122,7 +120,7 @@ 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, self.passed_info['interaction_context'].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: