A simple discord bot that will query your minecraft server and allow administrators to run commands without having to log in.
This implementation uses the RCON protocol, so it can even run with a vanilla server.
It is highly recommended to run this bot on the same machine that hosts the server, since Minecraft's RCON protocol is unencrypted and insecure, and therefore should not be exposed to the internet.
Either clone this repo and run cargo build --release
(requires cargo and rustc >= 1.65), or download one of the releases.
The following environment variables must be set before running the bot:
OP_ROLE_ID
: The ID of the discord role which is given to server operators (users without said role will not be allowed to run commands).RCON_ADDR
: The address and port of your server. Use the IP127.0.0.1
if running locally (recommended).
The default port that comes with every server is 25575 (this is specified inserver.properties
), therefore when using the IP above the full address would be127.0.0.1:25575
.RCON_PASS
: The RCON password as configured inserver.properties
.DISCORD_TOKEN
: The token of your discord bot.LIST_CHANNEL_ID
: The ID of the channel where the self-updatinglist
message is going to be. This should be a dedicated channel for the bot.SERVER_DIR
: The path to the server's root directory (the one that contains the server jar,server.properties
, the world folder, etc).
Here's an example shell script similar to the one that I use:
#!/bin/sh
OP_ROLE_ID="<insert op role id here>" \
RCON_ADDR="127.0.0.1:25575" \
RCON_PASS="<insert rcon password here>" \
DISCORD_TOKEN="<insert discord bot token here>" \
LIST_CHANNEL_ID="<insert list channel id here>" \
SERVER_DIR="/path/to/server/root" \
\
./ferrisquery
Your discord bot must be authorized with the application.command
and bot
scopes, and must additionally have the "Send Messages" permission.
You must also verify the following in server.properties
:
enable-rcon
is set totrue
.rcon.port
andrcon.password
are correctly configured (note: Minecraft treats the\
character (along with some others) as special, so be aware of that when creating your password. I recommend setting a random, long, strictly alphanumeric password to avoid problems.
Also note that the password is just a precaution, since as mentioned earlier your RCON port should not be open to the internet in the first place.- Optionally, set
broadcast-rcon-to-op
tofalse
to prevent spamming the chat with the periodiclist
executions.