Dav-Git / Dav-Cogs

Dav's cogs for Red-DiscordBot
GNU General Public License v3.0
33 stars 28 forks source link

[Feature] Support Whitelisting via Pterodactyl Panel API #96

Closed Kas-tle closed 3 years ago

Kas-tle commented 3 years ago

Pterodactyl Panel is an open source server management panel for Minecraft and other games. It allows GUI based management of Docker containers to easily run multiple containerized servers on the same machine. The community has even created an "egg", which is basically a defined container setup, to easily install RedBot. In addition to self hosted instances, many server hosting providers sponsor and use modified forks of the panel. You can see the list here.

The panel also has a robust API to allow actions like running commands in a given server container. As such, I would like to request support for this API with the whitelist cog. This could work by using the "Send Command" action in the API to use Minecraft's vanilla whitelist management command. For example:

import requests

# Input
panel_domain = "example.com"
apikey = "somekey"
username = "someuser"
server_id = "someid"

# Request Components
url = "https://" + panel_domain + "/api/client/servers/" + server_id + "/command"
headers = {
    "Authorization": "Bearer " + apikey,
    "Accept": "application/json",
    "Content-Type": "application/json"
}
payload = {
  "command": "whitelist add " + username
}

# Send Request
response = requests.request('POST', url, data=payload, headers=headers)
print(response.text)
Dav-Git commented 3 years ago

Hey, thanks for the suggestion, however Ptero is not a supported host for red.

There are plans to make the COG work via RCON, but I won't be supporting the Ptero API as it is a rather niche use case.

Kas-tle commented 3 years ago

Understandable. However I would just note that while Pterodactyl hosting of Red may be a niche use case, Pterodactyl hosting of a Minecraft server is definitely not a niche use case, as there are major shared hosting providers that use the panel. This would allow those with shared hosting on these platforms to use the whitelist feature regardless of where their bot is hosted, and I would posit that it is arguably more niche to host red bot and a Minecraft server on the same machine in an non-containerized environment.