Minecraft Discord
Welcome to my GitHub
This is a Discord bot that you host yourself (tutorial below) that can tell you the status of your (or any public) Minecraft server and lists the players online. More functions listed below.
Table of Contents
Running the bot
To run this bot, just start run.py in Python3
To change settings in this bot, run configure.py in Python3
You don't need to run configure.py on the first run as there is a first time setup.
Prerequisites
You need Python 3.5.9+ and a stable internet connection in order to run this bot. When the code is run, it should automatically install the following libraries using pip3:
- mcstatus
- status
- dotenv
- discord.py
If this doesn't happen, please report it as an issue and install them manually. pip3 should automatically install if you don't already have it.
Server Settings
Make sure you have your server properties set to enable-query=true so that you can get the server information
Hardware
You can run this bot on just about any hardware that can run Python but if you don't have a device that can keep this bot hosted 24/7, I would recommend using a Raspberry Pi. They run Linux, are low cost, use very little power and are capable of running this code without an issue.
Default commands
- map - Displays the online map if you have one installed on your server
- server - Displays the public server address
- help - Displays all default bot commands
- download - Allows users to download the worlds if you have them publicly hosted
- status - Checks to see if the server is up and lists online players
- minecraftNickname - Sets the nickname to be used for 'status'
- source - Displays the source code of this bot
You can add your own commands in the custom file which is created on setup
Setting up the Discord bot
-
Go to the Discord developer site
-
Create a Bot User by navigating to the “Bot” tab and clicking “Add Bot”.
-
Make sure that Public Bot is ticked if you want others to invite your bot.
-
You should also make sure that Require OAuth2 Code Grant is unchecked unless you are developing a service that needs it. If you’re unsure, then leave it unchecked.
-
Copy the token using the “Copy” button.
Warning: It should be worth noting that this token is essentially your bot’s password. You should never share this to someone else. In doing so, someone can log in to your bot and do malicious things, such as leaving servers, ban all members inside a server, or pinging everyone maliciously.
The possibilities are endless, so do not share this token.
If you accidentally leaked your token, click the “Regenerate” button as soon as possible. This revokes your old token and re-generates a new one. Now you need to use the new token to login.
Inviting your bot
-
Set the permissions required for the bot. For this Minecraft bot we only need the following permissions:
- Send Messages
- Manage Messages
- Embed Links
- Attach Files
- Read Message History
You can set as many permissions as you'd like which may be needed if you want to add your own code to this bot.
- Now the resulting URL can be used to add your bot to a server. Copy and paste the URL into your browser, choose a server to invite the bot to, and click “Authorize”.