Overview
Do you want a Discord Bot to start your Minecraft server? This program will help you do just that!
Features
This script starts your Minecraft server and shuts it down too! It also shuts down the server when it's inactive.
Commands
There are 6 commands that can be used by anyone:
/start
will start the Minecraft server if it's not already running./stop
will shut down the Minecraft server if no players are online./info
will give you the server information./ipcheck
will check the server address given in$info
. The bot will try to update the server address on its own if the address doesn't work./say <message>
will send a message in the Minecraft server if it's running. The message will appear as{username#0000} <message>
. Note that this is only one-way and that Minecraft to Discord chat integration hasn't been implemented yet./help
can be used to get information on these commands on Discord.
These commands can be used only by the user(s) set in server-op
:
/cmd
will execute a Minecraft command. For example,/cmd time set 0
. The bot will respond with the output, in this caseRcon: Set the time to 0
./ipset
will take a new server address and check it. If it's valid, the bot will start using that address moving forward (will be reset if the bot restarts).
Installation
Follow these steps:
Setting up the Discord bot
Do this part ONLY IF you are setting this up for the first time! If you set your bot up previously but are using slash commands on it for the first time, please redo the steps carefully.
Go to the Discord Developer site, and create a new application. Now go to the "Bot" section and build a bot. Head over to the "OAuth2" section, and under it, the "URL Generator" section. Under "Scopes", check bot
and applications.commands
. Under "Bot Permissions", select the permissions "Send Messages", "Read Message History". At the very bottom, there will be a "Generated URL". Copy it and paste it in your browser. This will allow you to invite your bot to your server.
Setting up the Minecraft server
If you haven't already, set up your Minecraft server on your machine as normal. Now go to your server.properties
file. Change the following values:
enable-rcon=true
rcon.password=<password>
, where is the password you wish to use for Rcon.
Setting up the Bot variables
Open the file named bot.env
.
- Paste your Discord bot token next to
bot-token
. - Paste the server address that other players would use to connect next to
server-address
. - Paste the server start script next to
start-script
. (For example,start-script=java -Xmx2G -Xms512M -jar server.jar
) - Paste the user ID of the account that shall be allowed to execute commands through Rcon next to
server-op
. If you want multiple users, separate each one with,
. For example:server-op=123,456,243,632
. Do not use spaces.
Important notes
- Minecraft connects to port 25565 by default. If you forward any port other than 25565, your address would look something like
xxx.xxx.xxx.xxx:port
since the port must also be specified for Minecraft. This CAN be set inbot.env
, in which case the program pings the server onport
. However, if you use port 25565, you may leave the address asxxx.xxx.xxx.xxx
and the program will use port 25565 automatically.