Refactor Pterodactyl cog to use aiohttp #2
1 changed files with 2 additions and 5 deletions
|
@ -20,7 +20,7 @@ class Pterodactyl(commands.Cog):
|
||||||
startup_arguments=None
|
startup_arguments=None
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_session(self, guild, endpoint = None):
|
async def get_session(self, guild):
|
||||||
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:
|
||||||
|
@ -32,10 +32,7 @@ class Pterodactyl(commands.Cog):
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Accept": "application/json"
|
"Accept": "application/json"
|
||||||
}
|
}
|
||||||
url = f"https://{await self.config.guild(guild).base_url()}/api/client/servers/{await self.config.guild(guild).server_id()}"
|
async with aiohttp.ClientSession(headers=headers) as session:
|
||||||
if endpoint:
|
|
||||||
url += '/' + endpoint
|
|
||||||
async with aiohttp.ClientSession(url=url, headers=headers) as session:
|
|
||||||
return session
|
return session
|
||||||
|
|
||||||
async def get_url(self, guild, endpoint = None):
|
async def get_url(self, guild, endpoint = None):
|
||||||
|
|
Reference in a new issue