feat(pterodactyl): use red's api key storage system for api key storage and not a config key
Some checks failed
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 19s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 24s

This commit is contained in:
SeaswimmerTheFsh 2024-03-01 01:17:31 -05:00
parent 7e03696e10
commit afc5868e9e
Signed by: cswimr
GPG key ID: B8953EC01E5C4063
2 changed files with 19 additions and 11 deletions

View file

@ -1,6 +1,6 @@
import asyncio
import json
from typing import Optional
from typing import Mapping, Optional
import discord
import websockets
@ -76,6 +76,13 @@ class Pterodactyl(commands.Cog):
command = command.replace(".$U", username).replace(".$M", message).replace(".$C", str(color))
return command
@commands.Cog.listener()
async def on_red_api_tokens_update(self, service_name: str, api_tokens: Mapping[str,str]):
if service_name == "pterodactyl":
logger.info("Configuration value set: api_key\nRestarting task...")
self.task.cancel()
self.task = self.get_task()
@commands.group(autohelp = True, name = "pterodactyl", aliases = ["ptero"])
async def pterodactyl(self, ctx: commands.Context) -> None:
"""Pterodactyl allows you to manage your Pterodactyl Panel from Discord."""
@ -100,15 +107,6 @@ class Pterodactyl(commands.Cog):
self.task.cancel()
self.task = self.get_task()
@pterodactyl_config.command(name = "apikey")
async def pterodactyl_config_api_key(self, ctx: commands.Context, *, api_key: str) -> None:
"""Set the API key for your Pterodactyl Panel."""
await config.api_key.set(api_key)
await ctx.send(f"API key set to `{api_key[:5]}...{api_key[-4:]}`")
logger.info("Configuration value set: api_key = %s\nRestarting task...", api_key)
self.task.cancel()
self.task = self.get_task()
@pterodactyl_config.command(name = "serverid")
async def pterodactyl_config_server_id(self, ctx: commands.Context, *, server_id: str) -> None:
"""Set the server ID for your Pterodactyl Panel."""