Discord on a self-hosted server
Create an application in the Discord Developer Portal. One application serves every Discord server connected to this GitNotify instance.
Create the application
Section titled “Create the application”- Create a new application and give it a name.
- On General Information, copy the Application ID and Public Key.
- On Bot, create or reset the bot token and copy it once.
- Leave the privileged gateway intents off. GitNotify does not use the gateway or read messages.
Set these environment variables:
DISCORD_APPLICATION_ID=replace-with-the-application-idDISCORD_PUBLIC_KEY=replace-with-the-public-keyDISCORD_BOT_TOKEN=replace-with-the-bot-tokenDISCORD_INTERACTIVE=1DISCORD_INTERACTIVE=1 adds incident ownership buttons. Leave it unset only if you do not want those buttons.
Apply the change with docker compose -f selfhosted/docker-compose.yml up -d gitnotify before you continue. Discord checks both endpoints below when you save them, and they answer 503 until the public key is loaded.
Configure the HTTP endpoints
Section titled “Configure the HTTP endpoints”Set the Interactions Endpoint URL to:
https://gitnotify.example.com/discord/interactionsGitNotify also uses Discord Event Webhooks to record when the app is authorized for a server. Set the Event Webhooks endpoint to:
https://gitnotify.example.com/discord/eventsSubscribe to the APPLICATION_AUTHORIZED event. The endpoint also safely acknowledges other event types. Both endpoints verify Discord's Ed25519 signature with DISCORD_PUBLIC_KEY and return 503 until that key is configured.
Register the slash commands
Section titled “Register the slash commands”GitNotify does not register commands on startup. After the bot token, application ID, and ADMIN_TOKEN are set, call the admin route once:
ADMIN_TOKEN=$(grep '^ADMIN_TOKEN=' selfhosted/.env | cut -d= -f2-)curl -fsS -X POST "http://127.0.0.1:8000/admin/discord/commands" \ -H "Authorization: Bearer $ADMIN_TOKEN"The route replaces the application's global command set with GitNotify's current commands. Run it again after a release changes the command definitions.
Install the application
Section titled “Install the application”Use this URL, replacing YOUR_APPLICATION_ID:
https://discord.com/oauth2/authorize?client_id=YOUR_APPLICATION_ID&scope=bot%20applications.commands&permissions=805391376&integration_type=0The permission value 805391376 contains:
- Manage Channels
- Manage Roles
- Manage Webhooks
- View Channel
- Send Messages
- Embed Links
- Read Message History
It does not include Administrator.
After installation, run /github connect as someone with Manage Server, choose repositories, and then run /setup. Other members can use /link to receive their own review and incident notifications. The commands and setup steps are the same as on the hosted GitNotify: see Discord.