misc(pterodactyl): moved configuration calls into establish_websocket_connection

This commit is contained in:
Seaswimmer 2024-02-28 08:11:15 -05:00
parent 6e6559d80c
commit 9d4d8b8267
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -25,7 +25,10 @@ class Pterodactyl(commands.Cog):
self.client = None
self.websocket = None
async def establish_websocket_connection(self, base_url, api_key, server_id):
async def establish_websocket_connection(self):
base_url = await self.config.base_url()
api_key = await self.config.api_key()
server_id = await self.config.server_id()
try:
client = PterodactylClient(base_url, api_key).client
websocket_credentials = client.servers.get_websocket(server_id)
@ -61,10 +64,7 @@ class Pterodactyl(commands.Cog):
self.logger.debug("Received message: %s", message)
async def cog_load(self):
base_url = await self.config.base_url()
api_key = await self.config.api_key()
server_id = await self.config.server_id()
await self.establish_websocket_connection(base_url, api_key, server_id)
await self.establish_websocket_connection()
async def cog_unload(self):
await self.client._session.close()