This repository has been archived on 2024-03-07. You can view files and clone it, but cannot push or open issues or pull requests.
GalacticCogs/pterodactyl/ptero.py

35 lines
1.2 KiB
Python
Raw Normal View History

2023-07-14 11:04:58 -04:00
from redbot.core import commands, Config
class Pterodactyl(commands.Cog):
"""Pterodactyl allows you to manage your Pterodactyl Panel from Discord."""
def __init__(self, bot):
self.bot = bot
self.config = Config.get_conf(self, identifier=457581387213637448123567)
self.config.register_guild(
2023-07-14 11:04:58 -04:00
base_url="pterodactyl.file.properties",
api_key=None,
server_id="d6d05b41-4da5-4c5b-9ee6-6e25f61a596b"
)
def get_url(self, ctx, endpoint = None):
"""Returns the base url for the Servers API, or the url for a specific endpoint if one is provided."""
if not self.config.guild(ctx.guild).server_id():
raise LookupError("Server ID not set.")
base_url = self.config.guild(ctx.guild).base_url()
server_id = self.config.guild(ctx.guild).server_id()
url = f"https://{base_url}/api/client/servers/{server_id}/"
if endpoint:
url += endpoint
return url
@commands.command()
async def test(self, ctx, endpoint = None):
"""This does stuff!"""
# Your code will go here
if endpoint:
url = self.get_url(ctx, endpoint)
else:
url = self.get_url(ctx)
2023-07-14 11:10:16 -04:00
await ctx.send(url)