Skip to main content

Discord

KhunQuant connects to Discord using the Discord Gateway (WebSocket). The DiscordChannel adapter listens for incoming messages and dispatches responses back to the originating channel or thread. No public URL is required — the connection is established outbound from your server.

Capabilities

  • Text message send/receive
  • Typing indicator (TypingCapable)
  • Slash command registration (CommandRegistrarCapable)
  • Allow-listing by Discord user ID
  • Voice channel join/leave with audio transcription
  • Media attachment transcription (audio files)

Configuration

Add to ~/.khunquant/config.json:

{
"channels": {
"discord": {
"enabled": true,
"token": "DISCORD_BOT_TOKEN",
"allow_from": ["123456789012345678"],
"group_trigger": {
"mention_only": true,
"prefixes": ["/ask"]
}
}
}
}

Store the bot token in ~/.khunquant/.security.yml:

channels:
discord:
token: "MTIzN..."
FieldTypeDescription
enabledboolEnable the Discord channel
tokenSecureStringBot token from the Discord Developer Portal
allow_from[]stringAllowlist of Discord user IDs (empty allows all)
group_trigger.mention_onlyboolOnly respond when the bot is @mentioned in a server channel
group_trigger.prefixes[]stringAdditional keyword triggers (e.g. /ask, !bot)

Setup steps

  1. Go to the Discord Developer Portal and create a new application.
  2. Navigate to Bot and click Add Bot — copy the bot token.
  3. Under Bot → Privileged Gateway Intents, enable Message Content Intent.
  4. Add the token to .security.yml.
  5. Enable Developer Mode in Discord (Settings → Advanced) and right-click your avatar to copy your User ID for allow_from.
  6. Use the OAuth2 URL Generator with the bot and applications.commands scopes plus Send Messages and Read Message History permissions to invite the bot to your server.
  7. Start KhunQuant.

Voice channels

The bot can join a voice channel to transcribe audio in real time. Use these in-chat commands:

CommandDescription
!vc joinJoin the voice channel you are currently in
!vc leaveLeave the current voice channel

Voice transcription requires an ASR model to be configured. See the model configuration guide for details.

Server channels vs DMs

In direct messages the bot replies to every message. In server channels it defaults to responding only when @mentioned (mention_only: true). Adjust group_trigger to match your preferred behaviour.