Discord Integration
Currently MineTrax has these integration with Discord:
- Social Authentication (OAuth)
- Discord Notifications (with Bot)
- Serverlog (Webhook)
Future planned integrations:
- Role Sync with Linked Roles feature
- Interactions with Bot
Setup Discord OAuth and Bot for Notifications
1. Create application in Discord for OAuth and Bot.
-
Go to Discord Developers Portal and create a new application by clicking on
New Application
button at top right. You can name it anything you like. -
Now go to
OAuth2
tab and note downCLIENT ID
andCLIENT SECRET
from there. You will have toReset Secret
once to view it. -
You now need to add a Redirect URL, Use the
Add Redirect
button to do this. Your URL will be your base domain with/auth/discord/callback
added onto the end. For example for basehttps://minetrax.world
our callback becomeshttps://minetrax.world/auth/discord/callback
. Enter the callback there and clickSave Changes
. -
Next go to
Bot
tab, and find yourTOKEN
(You will have toReset Token
once to view it). Copy and note down the that bot token we will need it in next steps. -
Now open your
.env
file in minetrax directory and update these variables as follow..envDISCORD_OAUTH_ENABLED=true #Set it to `true` if `false`
DISCORD_CLIENT_ID= #Enter your CLIENT ID here
DISCORD_CLIENT_SECRET= #Enter your CLIENT SECRET here
DISCORD_REDIRECT_URI="${APP_URL}/auth/discord/callback" #Leave it as it is.
DISCORD_BOT_TOKEN= #Enter your Bot Token hereExample:
DISCORD_OAUTH_ENABLED=true
DISCORD_CLIENT_ID=865111111111111111
DISCORD_CLIENT_SECRET=Qfsdalf_45-b222-o0E_aAMklasdjf
DISCORD_REDIRECT_URI="${APP_URL}/auth/discord/callback"
DISCORD_BOT_TOKEN=ODY1NzQ2OTMyMdkaslfjsdfl.Gn7gAZ.3954sdalfasdflh0945353409 -
Run update
sh update.sh
so that the changes get reflected in the application.cd /var/www/minetrax
sh update.sh
2. Add Bot to your server
-
Open your minetrax directory in SSH and run
php artisan discord:setup
to initialize the process.cd /var/www/minetrax
php artisan discord:setup -
It will ask if the bot is already added to your server. Type
no
and enter. -
Next it will ask you for CLIENT ID. Enter the CLIENT ID which you entered in
.env
, and then press Enter. -
It will give you a link which you should click and follow the instructions to add the Bot to your Discord Server.
-
Once its added come back to the prompt and type
yes
and press Enter. -
It will do few checks and everything should complete and you should see a message
Your bot has been identified by Discord and can now send API requests!
. -
Done.
For notification to work for a user, they will need to login with Discord at least once after you have setup the Discord OAuth and Bot.
Next time whenever your user login with Discord, it will automatically link their account with Discord and do everything require to send notifications to him in DM.