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 09d48082e5 - Show all commits

View file

@ -74,11 +74,11 @@ class Pterodactyl(commands.Cog):
websocket_credentials = client.servers.get_websocket(server_id) websocket_credentials = client.servers.get_websocket(server_id)
continue continue
async def get_task(self): def get_task(self):
return self.bot.loop.create_task(await self.establish_websocket_connection(), name="Pterodactyl Websocket Connection") return self.bot.loop.create_task(self.establish_websocket_connection(), name="Pterodactyl Websocket Connection")
async def cog_load(self): async def cog_load(self):
self.task = await self.get_task() self.task = self.get_task()
async def cog_unload(self): async def cog_unload(self):
self.task.cancel() self.task.cancel()
@ -99,7 +99,7 @@ class Pterodactyl(commands.Cog):
await ctx.send(f"Base URL set to {base_url}") await ctx.send(f"Base URL set to {base_url}")
self.logger.debug("Configuration value set: base_url = %s\nRestarting task...", base_url) self.logger.debug("Configuration value set: base_url = %s\nRestarting task...", base_url)
self.task.cancel() self.task.cancel()
self.task = await self.get_task() self.task = self.get_task()
@pterodactyl_config.command(name = "apikey") @pterodactyl_config.command(name = "apikey")
async def pterodactyl_config_api_key(self, ctx: commands.Context, api_key: str): async def pterodactyl_config_api_key(self, ctx: commands.Context, api_key: str):
@ -108,7 +108,7 @@ class Pterodactyl(commands.Cog):
await ctx.send(f"API key set to `{api_key[:5]}...{api_key[-4:]}`") await ctx.send(f"API key set to `{api_key[:5]}...{api_key[-4:]}`")
self.logger.debug("Configuration value set: api_key = %s\nRestarting task...", api_key) self.logger.debug("Configuration value set: api_key = %s\nRestarting task...", api_key)
self.task.cancel() self.task.cancel()
self.task = await self.get_task() self.task = self.get_task()
@pterodactyl_config.command(name = "serverid") @pterodactyl_config.command(name = "serverid")
async def pterodactyl_config_server_id(self, ctx: commands.Context, server_id: str): async def pterodactyl_config_server_id(self, ctx: commands.Context, server_id: str):
@ -117,4 +117,4 @@ class Pterodactyl(commands.Cog):
await ctx.send(f"Server ID set to {server_id}") await ctx.send(f"Server ID set to {server_id}")
self.logger.debug("Configuration value set: server_id = %s\nRestarting task...", server_id) self.logger.debug("Configuration value set: server_id = %s\nRestarting task...", server_id)
self.task.cancel() self.task.cancel()
self.task = await self.get_task() self.task = self.get_task()