Package: craftlink
CraftLinkA Discord bot to control a Minecraft server remotely.ExamplesStarting, Stopping, Sending Commands (Bedrock and Java)Command/sayfrom In-Game POVSecurity DisclaimerWhile 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 RestrictionsSince 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...!SetupDependenciesRequires Python 3.9+.Install viapip install craftlink.Or, clone and runpoetry installto install from source.You'll need to downloadthe Bedrock Server,
orthe Java server.You'llprobablywant 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>/worldfolder (Java).Operating SystemCurrently supports Windows and Linux (tested on Debian).Likely works on MacOS, but not yet tested.RunningTo run locally, just invokecraftlinkwith 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 BedrockYou must use the switch--isarm-64and set the environment variableIS_ARM64so the command is dispatched correctly.The Bedrock binary is meant for x86_64 architecture; to get it to run
on arm64 devices,box64emulation is used.If building the Bedrock Docker image, specify--platform=linux/arm64andbox64will be installed automatically.Otherwise, ensure your system hasbox64installed and available in thePATH.(Shoutout tothis issue commentfromdocker-minecraft-bedrock-serverfor pointing me in the right direction here.)DockerTo run in a Docker container, you'll need to ensure your.envfile is populated first.
Copy.env.templateand fill in the blanks.
Ensure thatSERVER_INSTALL_DIRECTORYis 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.propertiesworldsFor Java, the entire directory will be mounted.Regardless of server type, ensure you run the world locally once before mounting it.When ready, rundocker compose up <server_type: java or bedrock>to run.ImprovementsAdd 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.Support for modded server launchers.Affiliate DisclaimerIn no way affiliated with Microsoft or Mojang (that'd be dope though, feel free to reach out, folks).