diff --git a/pterodactyl/__init__.py b/pterodactyl/__init__.py new file mode 100644 index 0000000..bfb77fa --- /dev/null +++ b/pterodactyl/__init__.py @@ -0,0 +1,5 @@ +from .ptero import Pterodactyl + + +async def setup(bot): + await bot.add_cog(Pterodactyl(bot)) diff --git a/pterodactyl/info.json b/pterodactyl/info.json new file mode 100644 index 0000000..a0631f1 --- /dev/null +++ b/pterodactyl/info.json @@ -0,0 +1,8 @@ +{ + "author" : ["SeaswimmerTheFsh"], + "install_msg" : "Thank you for installing Pterodactyl!\nYou can find the source code of this cog here: https://git.seaswimmer.cc/GalacticFactory/GalacticCogs", + "name" : "Pterodactyl", + "short" : "Interacts with the Pterodactyl API to assist in server management.", + "description" : "Interacts with the Pterodactyl API to assist in server management. Read the Pterodactyl API Docs here: https://dashflo.net/docs/api/pterodactyl/v1/", + "end_user_data_statement" : "This cog does not store any End User Data." + } diff --git a/pterodactyl/ptero.py b/pterodactyl/ptero.py new file mode 100644 index 0000000..6d016ad --- /dev/null +++ b/pterodactyl/ptero.py @@ -0,0 +1,34 @@ +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_server( + 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) + await ctx.send("I can do stuff!")