- Introduction
- Features
- Roadmap
- Installation
- Usage
- Issues
- Contributing
- Support the Project
- Donations
- License
Warning
This project is still in development and is not yet ready for production use. Please use it at your own risk.
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 List: Get a list of all servers
- Server Backup: Create a backup of the server
- Auto complete (slash commands): Auto complete the server ID
- 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
- 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:
Important
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.
- 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
- 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.
Important
Replace YOUR_DISCORD_TOKEN
with your Discord bot token, YOUR_CRAFTY_TOKEN
with your Crafty Controller API token
and YOUR_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:latest
Or you can use the following docker-compose.yml
file:
services:
crafty-bot:
image: twoplay/craftybot:latest
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 copy the .env.example
file to a new file called .env
and fill in the required
fields.
Only the DISCORD_TOKEN
and CRAFTY_TOKEN
fields are required to run the bot. If you want to use slash commands, you
will need to fill in the GUILD_ID
field as well.
Start the bot
```bash
cd core
python main.py
Replace YOUR_DISCORD_TOKEN
with your Discord bot token and CRAFTY_TOKEN
with your Crafty Controller API token.
For updating the bot, you can use the following command:
# Change into the project directory and pull the latest changes
cd Crafty-Discord-bot
git pull
To use slash commands, you will need to set the GUILD_ID
in the .env
file. You can get the GUILD_ID
by enabling
the Developer Mode
in Discord and right-clicking on the server name.
To get the slash commands, enter the following command:
>clear
>commands
>sync
Hopefully, the bot will know the commands. It is still in beta, so it may not work as expected.
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
Enter the following command to get a list of available commands:
>help
To get the status of the server, enter the following command:
>status
To start the server, enter the following command:
>start [server_id]
replace [server_id]
with the ID of the server you want to start. You can get the server ID by entering the >list
command.
For example:
>start da459ce3-6964-46b8-bb21-1c3e753b6ba9
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.