Add Pterodactyl cog #19

Merged
cswimr merged 139 commits from pterodactyl into main 2024-03-02 00:07:42 -05:00
Showing only changes of commit 9d4d8b8267 - Show all commits

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()