initial petrodactyl manager commit
This commit is contained in:
parent
3bae4de445
commit
53742a977f
3 changed files with 47 additions and 0 deletions
5
pterodactyl/__init__.py
Normal file
5
pterodactyl/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from .ptero import Pterodactyl
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(Pterodactyl(bot))
|
8
pterodactyl/info.json
Normal file
8
pterodactyl/info.json
Normal file
|
@ -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."
|
||||||
|
}
|
34
pterodactyl/ptero.py
Normal file
34
pterodactyl/ptero.py
Normal file
|
@ -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!")
|
Reference in a new issue