Setup Class
The Setup class provides a way to configure global settings for the Pterodactyl API Wrapper. The primary use is to set the panel URL, which is then used in all API requests.
Written By Cptcr
Last updated 12 months ago
Setup Configuration
Before making any API requests, you must configure the panel URL using the Setup class. This URL will be used globally for all interactions with the Pterodactyl API.
const { Setup } = require("pterodactyl-api-wrapper"); Setup.setPanel("https://panel.example.com"); Class: Setup
Constructor
The Setup class does not require instantiation, as it only contains static methods.
Methods
setPanel(url: string)
Sets the global panel URL.
Parameters:
url(string): The URL of the Pterodactyl panel.
Example Usage:
Setup.setPanel("https://panel.example.com"); getPanel()
Gets the globally set panel URL.
Returns:
string: The panel URL.
Throws:
An error if the panel URL has not been set.
Example Usage:
const panelUrl = Setup.getPanel(); console.log("Panel URL:", panelUrl); Error Handling
If the panel URL is not set before making API calls, the getPanel() method will throw an error:
try { const panelUrl = Setup.getPanel(); } catch (error) { console.error(error.message); // "Panel URL is not set. Use Setup.setPanel(url) before making API calls." } Conclusion
The Setup class is an essential part of the pterodactyl-api-wrapper, ensuring that all API requests are directed to the correct panel. Proper configuration of the panel URL before making any API calls is required to avoid errors.