This code represents a Discord bot custom built for the 7th Cavalry Gaming Regiment that interacts with the Discord API using the discord.py
library. The bot provides functionality to restart servers running on Pterodactyl through slash commands.
- Python 3.7 or higher
discord.py
libraryaiohttp
library
-
Install the required libraries by running the following command:
pip install discord.py aiohttp
-
Obtain a Discord bot token:
- Create a new Discord application and bot on the Discord Developer Portal.
- Copy the bot token and set it as the value of the
BOT_TOKEN
environment variable.
- Obtain an API key for server control:
- Acquire an API key from the appropriate server control panel.
- Set the API key as the value of the
API_KEY
environment variable.
- Configure the server dictionary:
- Edit the
servers_dict
variable in the code to include the desired server names and their corresponding server IDs.
- Customize the bot behavior (optional):
- Modify the
status
variable to set the bot's activity. - Customize the error handling behavior in the
on_command_error
function.
-
Run the script:
python main.py
-
The bot will log in to Discord using the provided bot token and connect to the specified guild.
-
Interact with the bot on Discord:
- Use the
/restart_server
command followed by the desired server name to restart a server. - Only users with the appropriate roles will be able to use the command successfully.
Feel free to contribute to this code by submitting issues or pull requests on the GitHub repository.
This code is licensed under the MIT License.