misc: minor changes to get_url

This commit is contained in:
Seaswimmer 2023-07-15 23:33:33 -04:00
parent 55067cb269
commit 9be254e983
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -20,16 +20,16 @@ class Pterodactyl(commands.Cog):
) )
async def get_url(self, guild, endpoint = None): async def get_url(self, guild, endpoint = None):
"""Returns the base url for the Servers API, or the url for a specific API endpoint if one is provided.""" """Returns the base url for the server's API, or the url for a specific API endpoint if one is provided."""
if await self.config.guild(guild).server_id() is None: if await self.config.guild(guild).server_id() is None:
raise LookupError("Server ID not set.") raise LookupError("Server ID not set.")
elif await self.config.guild(guild).base_url() is None: elif await self.config.guild(guild).base_url() is None:
raise LookupError("Base URL not set.") raise LookupError("Base URL not set.")
base_url = await self.config.guild(guild).base_url() base_url = await self.config.guild(guild).base_url()
server_id = await self.config.guild(guild).server_id() 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: if endpoint:
url += endpoint url += '/' + endpoint
return url return url
async def put(self, url: str, headers: dict, data: dict): async def put(self, url: str, headers: dict, data: dict):