Mik Music

Mik’s cool self-hosted music-bot.

Disclaimer

For legal reasons: There is no official public instance of this bot, so don’t bother asking

Platform Support

  • All native Lavaplayer platforms
  • Spotify

Features

  • slash-commands for everything
  • Queue songs from context actions (Also supports Discord file
    uploads) (DEMO)
  • Music channel (
    Like Hydra) (DEMO)
  • Bot internal playlist system (Supports import from other sources, just
    do /playlist add name: <name> query: <existing yt/spotify playlist>)
  • i18n (although most strings are only English as of rn)
  • Song guizes (Inpired by the AirConsole
    game MusicGuess)
  • UNO as a minigame – Just don’t even ask why

Deployment

Requirements

Required permissions: 328576854080

Example Environment file

.env

ENVIRONMENT=PRODUCTION
SENTRY_TOKEN=<>
DISCORD_TOKEN=<>
GAMES=p: some funny games,w: unfunny funny compilations on YouTube,l: to silence,p: lästert über aktuelle Musik,p: lästert über aktuelle Musik,p: Würde lieber Justin Bieber hören,p: Würde lieber Justin Bieber hören
MONGO_URL=mongodb://bot:bot@mongo
MONGO_DATABASE=bot_prod
LOG_LEVEL=DEBUG
YOUTUBE_API_KEY=<>
SPOTIFY_CLIENT_SECRET=<>
SPOTIFY_CLIENT_ID=<>
REDEPLOY_HOST=<>
REDEPLOY_TOKEN=<>
BOT_OWNERS=416902379598774273
OWNER_GUILD=<>

Starting the bot

Docker image from: https://github.com/DRSchlaubi/mikmusic/pkgs/container/mikmusic%2Fbot

  • Clone this repo
  • Run docker-compose up -d mongo
  • Run docker-compose exec mongo mongo -u bot -p bot
  • Run this mongo shell commands

use bot_prod
db.createCollection("lavalink_servers")
db.lavalink_servers.insertOne({"url": "wss://...", "password": "<password>"})
  • Run docker-compose up -d

Redeployment

Section inspired by Devcordbot

This section describes how to properly setup /redeploy
Service installation: https://github.com/adnanh/webhook

Env vars REDEPLOY_HOST,REDEPLOY_TOKEN,OWNER_GUILD and BOT_OWNERS need to be set

hooks.json

{
  "id": "redeploy-mikmusic",
  "execute-command": "/usr/bin/sh",
  "pass-arguments-to-command": [
    {
      "source": "string",
      "name": "/path/to/mikmusic/redeploy.sh"
    }
  ],
  "command-working-directory": "/path/to/mikmusic",
  "trigger-rule": {
    "match": {
      "type": "value",
      "value": "YOUR_SECRET_TOKEN",
      "parameter": {
        "source": "header",
        "name": "Redeploy-Token"
      }
    }
  }
}

redeploy.sh

#!/usr/bin/env sh
docker-compose pull && docker-compose up -d
Guild verification

If you want to run a “public” instance of this bot, but limit the people who can use it you can turn on verification
mode

.env changes

VERIFIED_MODE=true
VERIFY_SERVER_URL=<The webserver>
VERIFY_CLIENT_ID=<Discord client id>
VERIFY_CLIENT_SECRET=<Discord client secret (NOT BOT TOKEN)>
VERIFY_SERVER_HOST=0.0.0.0

OAuth2 Grant

Set require oauth 2 grant to true in the Discord bot settings

Note It’s recommended to setup a reverse proxy for the verification server

For developers

JDK is required it can be obtained here (Recommended for Windows but works everywhere)
and here (Recommended for Linux/Mac)

Please set the ENVIRONMENT env var to DEVELOPMENT whilst developing the bot

GitHub

https://github.com/DRSchlaubi/mikmusic