CraftLink
A Discord bot to control a Minecraft server remotely.
Examples
Starting, Stopping, Sending Commands (Bedrock and Java)
Command /say from In-Game POV
Security Disclaimer
While there is some validation around the commands sent to the server, it is important to note that it is likely not secure.
It is very possible that this could be abused to send and execute malicious code!
Recommended Restrictions
Since this connection gives full control over a Minecraft server and it's various properties and settings, the bot requires and is limited to a single Discord channel within a Discord server.
It is recommended this channel be private and limited to only server admins and moderators.
Granular permissions based on Discord role may come eventually...!
Setup
Dependencies
Requires Python 3.9+.
Install via pip install craftlink.
Or, clone and run poetry install to install from source.
You'll need to download the Bedrock Server, or the Java server.
You'll probably want to run your server manually first to configure your world. You can migrate an
existing local world to be a server pretty easily by copying the world data into
<server_directory>/worlds (Bedrock), or replacing the <server_directory>/world folder (Java).
Operating System
Currently supports Windows and Linux (tested on Debian).
Likely works on MacOS, but not yet tested.
Running
To run locally, just invoke craftlink with the necesary arguments/environment variables set.
Required arguments:
-t,--discord-bot-token,DISCORD_BOT_TOKEN- Token to use to authenticate the Discord bot.-c,--discord-channel-id,DISCORD_CHANNEL_ID- Discord channel ID to target the bot's messages to.-d,--server-install-directory,SERVER_INSTALL_DIRECTORY- Directory that the server executable is in.
Optional arguments:
-y,--server-type,SERVER_TYPE- Type of server to be run ("bedrock" or "java"), defaults to bedrock.-m,--java-memory-min,JAVA_MEMORY_MIN- (Java only) minimum server memory to allocate, defaults to 1024.-x,--java-memory-max,JAVA_MEMORY_MAX- (Java only) maximum server memory to allocate, defaults to 1024.-is-arm64,IS_ARM64- Flag to indicate running on arm64 architecture.
ARM64 and Bedrock
You must use the switch --isarm-64 and set the environment variable IS_ARM64
so the command is dispatched correctly.
The Bedrock binary is meant for x86_64 architecture; to get it to run
on arm64 devices, box64 emulation is used.
If building the Bedrock Docker image, specify --platform=linux/arm64 and
box64 will be installed automatically.
Otherwise, ensure your system has box64 installed and available in the PATH.
(Shoutout to this issue comment
from docker-minecraft-bedrock-server
for pointing me in the right direction here.)
Docker
To run in a Docker container, you'll need to ensure your .env file is populated first.
Copy .env.template and fill in the blanks.
Ensure that SERVER_INSTALL_DIRECTORY is the directory to your local server files, not
the directory in the Docker image.
By default this image will mount existing server files from the host machine to the container. Note that for Bedrock, you only need to have the below files and folders, you don't need the executable/binary.
allowlist.jsonpermissions.jsonserver.propertiesworlds
For Java, the entire directory will be mounted.
Regardless of server type, ensure you run the world locally once before mounting it.
When ready, run docker compose up <server_type: java or bedrock> to run.
Improvements
- Add tests.
- Add user roles at the bot level to restrict certain actions.
- Could be multiple roles such that "admins" have all perms, "mods" have less, and "users" have none or just
/say.
- Could be multiple roles such that "admins" have all perms, "mods" have less, and "users" have none or just
- Support for modded server launchers.
Affiliate Disclaimer
In no way affiliated with Microsoft or Mojang (that'd be dope though, feel free to reach out, folks).
Release files for craftlink 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| craftlink-1.0.1.tar.gz | 11.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| craftlink-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.1 kB
Release files / craftlink-1.0.1.tar.gz
| Download URL | craftlink-1.0.1.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2560df1f3bf4f6e8796c12536e1b425a84b0f28fc6933120b10b05004ef840d
|
|
BLAKE2b-256 checksum How to use checksums |
dc368b12ccd91218f2bcb9ef097b007bccfdd9af70e329a9a8537313e027cc63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.9.6 Windows/10
|
Release files / craftlink-1.0.1-py3-none-any.whl
| Download URL | craftlink-1.0.1-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8739409491be96577fcbac702f0bb5de0b350b2b126640c5c864f043d2caefab
|
|
BLAKE2b-256 checksum How to use checksums |
003b1837268556b57bb922ad4b56f8d7ff31e618b07f25fce9a1866e3cc6c298
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.9.6 Windows/10
|