Initial Setup
Step 1: Setting Up the Database and Discord Bot
You can use either
MariaDB (self-hosted) or a
paid MySQL service to set up the database—both work equally well for the DisLink plugin. The bot manages the database connection automatically once configured.
- Database Setup: First, create a MySQL (or MariaDB) database that will store user mappings between Minecraft and Discord. Ensure you have:
- Hostname or IP address
- Database name
- Username
- Password
- Port (usually 3306)
- Discord Bot Setup: Follow these steps to set up the Discord bot that comes with the plugin:
- Create a new discord bot using this link. Grab it's ID, token and invite it into your server. Also grab the guild (server's) ID
- You’ll need to create the bot’s .env file with the following content:
DISCORD_TOKEN='your_bot_token'
CLIENT_ID=your_client_id
GUILD_ID=your_guild_id
DB_HOST=your_database_host
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_NAME=your_database_name
API_KEY=your_api_key
DB_PORT=3306
- API Key: This is a custom key for authenticating requests between the plugin and the bot. It must be a strong and unique string (use a UUID generator or strong password generator). This key will be shared between the bot and the plugin. Learn more about secure key generation here.
- Domain with SSL: The bot needs to be hosted on a domain with SSL to ensure secure communication. If you don't already have an SSL certificate, follow this guide from Let's Encrypt to set one up. In the bot's file, you will find two lines: 45 and 46. There, you'll have to set up the location of the privatekey and fullchain files.
- Start up the bot by running npm i followed by node index.js
- Running /dbconfig: To set up the database for the first time, simply run the command /dbconfig in your Discord server (you have to be the server's admin). The bot will reply with instructions on the next steps. You'll have 60 seconds to agree, otherwise the process will stop and you'll have to restart it.
- Done! Your discord bot is now configured.
Step 2: Setting Up the Plugin
Once the database and Discord bot are set up, you can configure the DisLink plugin:
- Download the plugin and place it in your Minecraft server’s plugins folder.
- Start the server to generate the config.yml file, then stop the server.
- Edit the config.yml file to include your database and Discord bot settings:
database:
ip: 'your_database_host'
port: 3306
name: 'your_database_name'
username: 'your_database_username'
password: 'your_database_password'
discordBotAndWebsite:
secret: 'your_api_key' #
This has to match the with the one you've set up earlier.
weblink: 'your_domain'
Using the Plugin
Once the plugin is running, players can use the following commands:
- /link <discord_username>: Links a player's Minecraft account with their Discord account.
- /unlink: Unlinks a player's accounts.
- /amilinked: Checks if the player is linked.
Each command is subject to a configurable cooldown (defined in config.yml), preventing spamming.
Verifying Accounts
To complete the linking process, the Discord bot will handle verification through the /verify command. When a user runs /link, they will receive a secret key in Minecraft that they need to verify in Discord.
Advanced Features
- Custom Discord Bot: The plugin comes with a fully customizable Discord bot source code. You can change the bot’s name, avatar, and even add custom commands to fit your server’s needs. With this, you can scale the bot to handle different use cases on your server.
- Easy Scalability: You can modify the bot’s code to add new features or commands easily, allowing you to extend its functionality as your server grows. I left a few functions at the end of the file go get you started.
For further assistance and external documentation: