- Introduction
- Features
- Roadmap
- Installation
- Usage
- Issues
- Contributing
- Support the Project
- Donations
- License
This is a Discord bot that is designed to control the Crafty-Controller-4 server. This is useful if friends want to start a server and you want to control it from Discord. The bot is written in Python and uses the Discord.py library to interact with the Discord API.
- Server Status: Get the status of the server
- Server Start: Start the server
- Server Stop: Stop the server
- Server Restart: Restart the server
- Server Backup: Create a backup of the server
- Web UI: Create a web interface for the bot
To install the bot, you will need to have a few things set up first.
You should have a Server to deploy this bot. You can use a VPS, local server or a Raspberry Pi. You can also use your own computer, but it is not recommended for availability reasons.
You will need to create a new user (recommended) on the Crafty Controller server and obtain the user token. You can do this by following these steps:
- Go to your Crafty Controller server
- Click on the gear icon in the top right corner
- Click on "add user" and enter a name for your user (for example, "Crafty Bot")
- Fill in the required fields, select the desired permissions and click on "Save"
- Click on the pencil icon next to the user you just created
- Click on "API Key" and select the following permissions:
- COMMANDS
- TERMINAL
- PLAYERS
INFO: I don't know if the permissions are correct, but you can try it out. If it doesn't work, please let me know. You can also use the "ALL" permission, but this is not recommended for security reasons.
- Enter a name for your user token (for example, "Crafty Bot Token")
- Click on "Create" to generate the user token
- Save your user token in a safe place (you will need it later)
You will need to create a new Discord bot and obtain a bot token. You can do this by following these steps:
- Go to the Discord Developer Portal
- Click on "New Application"
- Enter a name for your bot (for example, "Crafty Bot")
- Accept the terms and click on "Create"
- If you want to add an icon to your bot, click on "General Information" in the left-hand menu and then click on "Upload Image" under "App Icon"
- Click on "Bot" in the left-hand menu
- Under "username", you can change the name of your bot if you wish
- Disable the "Public Bot" option
- Click on "Reset Token" and confirm by clicking on "Yes, do it!"
- "Copy" under "Token" to copy your bot token
- Save your bot token in a safe place (you will need it later)
- Click on "OAuth2" in the left-hand menu
- Under "Scopes", select "bot"
- Under "Bot Permissions", select
- View Channels
- Send Messages
- Create public threads
- Use slash commands
- Read Message History
- Mention Everyone
INFO: I don't know if the permissions are correct, but you can try it out. If it doesn't work, please let me know. You can also use the "ALL / Administration" permission, but this is not recommended for security reasons.
- Click on "Copy" under "OAuth2 URL" to copy the invite URL
- Paste the invite URL into your web browser
- Select the server you want to invite the bot to
- Click on "Authorize"
Congratulations! Your bot has been invited to your server
Installing the bot using Docker is the easiest way to get started. To do this, you will need to have Docker installed on your system. If you do not have Docker installed, you can download it from the official Docker website.
Replace
YOUR_DISCORD_TOKEN
with your Discord bot token,YOUR_CRAFTY_TOKEN
with your Crafty Controller API token andYOUR_CRAFTY_SERVER_URL
with the URL of your Crafty Controller server in the following format:https://your-crafty-server-IP:PORT
.
To install the bot using Docker, you will need to run the following command in your terminal:
docker run -d --name crafty-bot -e DISCORD_TOKEN=YOUR_DISCORD_TOKEN -e CRAFTY_TOKEN=YOUR_CRAFTY_TOKEN -e SERVER_URL=YOUR_CRAFTY_SERVER_URL twoplay/craftybot:0.1
Or you can use the following docker-compose.yml
file:
services:
crafty-bot:
image: twoplay/craftybot:0.1
container_name: crafty-bot
environment:
- DISCORD_TOKEN=YOUR_DISCORD_TOKEN
- CRAFTY_TOKEN=YOUR_CRAFT
- SERVER_URL=YOUR_CRAFTY_SERVER_URL
restart: unless-stopped
If you would like to install the bot using Python, you will need to have Python 3.8 or higher installed on your system.
Clone the repository
git clone https://github.com/Two-Play/Crafty-Discord-bot.git
Change into the project directory
cd Crafty-Discord-bot
Create a virtual environment
python -m venv venv
Activate the virtual environment On Linux and macOS:
source venv/bin/activate
On Windows:
venv\Scripts\activate
Download the required dependencies
pip install -r requirements.txt
To run the bot, you will need to create a .env
file in the root directory of the project and add the following environment variables:
SERVER_URL=
DISCORD_TOKEN=
CRAFTY_TOKEN=
#For the login command (optional)
USERNAME=
PASSWORD=
Start the bot
python main.py
Replace YOUR_DISCORD_TOKEN
with your Discord bot token and YOUR_MONGO_URI
with your MongoDB connection string.
The bot supports slash commands. To use the slash commands, you will need to have the Use slash commands
permission enabled for the bot.
/help or /bot_help
Enter the following command to get a list of available commands:
>help or >bot_help
If you encounter any issues while using the bot, please report them on the GitHub Issues page.
If you would like to contribute to the project, please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature
) - Make your changes
- Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature
) - Create a new Pull Request
- Wait for your Pull Request to be reviewed
- Once your Pull Request is approved, it will be merged into the main branch
- Congratulations! You have successfully contributed to the project
Thank you for your contribution!
If you have any questions, please feel free to reach out to us
If you would like to support the project, you can do so by:
- Giving the project a star on GitHub
- Sharing the project with others
- Contributing to the project
- Donating to the project
If you would like to donate to the project, you can do so using the following methods:
Platform | Link | QR Code |
---|---|---|
Buy Me a Coffee | ||
PayPal |
You can click on the QR code to show a larger version of the QR code. GitHub does not support displaying large images in the README file.
This project is licensed under the MIT License - see the LICENSE.md file for details.