Consonance <-> Discord
Audio Stream Bot for Discord
Discord のボイスチャンネルにシステム音声(ループバック)をストリーミングする Bot。
2026年3月1日より Discord が全ボイス接続に DAVE (E2EE/MLS) プロトコルを強制したため、
v26.03.0 以降は disgoorg/disgo v0.19.2 + libdave.dll を使用する。
- Go 1.24 以上
- CGO 有効な環境
- C コンパイラ (MinGW64 GCC)
- pkg-config (pkgconfiglite)
- libdave v1.1.1 (Discord DAVE/E2EE プロトコル対応 — 下記参照)
- https://www.msys2.org/ からインストーラをダウンロードして実行(
C:\msys64にインストール) - "MSYS2 MSYS" を開き、アップデートを実施:
pacman -Syu pacman -Su
- MinGW64 の GCC をインストール:
pacman -S mingw-w64-x86_64-gcc
管理者権限の PowerShell で:
choco install pkgconfiglite -yPowerShell で:
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/disgoorg/godave/master/scripts/libdave_install.ps1" `
-OutFile "$env:TEMP\libdave_install.ps1"
& "$env:TEMP\libdave_install.ps1" -Version "v1.1.1"インストール後、新しい PowerShell を開き直すか以下を実行してパスを反映:
$env:PKG_CONFIG_PATH = [System.Environment]::GetEnvironmentVariable("PKG_CONFIG_PATH", "User")
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", "User") + ";" + $env:PATH付属の PowerShell スクリプトを使うのが最も簡単:
.\build-win.ps1または make:
make build-win手動で実行する場合:
$env:PKG_CONFIG_PATH = [System.Environment]::GetEnvironmentVariable("PKG_CONFIG_PATH", "User")
$env:PATH = "C:\msys64\mingw64\bin;" + [System.Environment]::GetEnvironmentVariable("PATH", "User") + ";" + $env:PATH
$env:CGO_ENABLED = "1"
go build -o ConsoNance.exe .
Copy-Item "$env:LOCALAPPDATA\libdave\bin\libdave.dll" "libdave.dll" -Forcelibdave.dll は MSVC でコンパイルされているため、MinGW GCC の free() で解放しようとするとヒープ破壊が発生する。
この問題は github.com/disgoorg/godave/libdave@v0.1.0 の utils.go に存在し、
C.free() を C.daveFree() に置き換えることで修正される。
ビルド前に以下で修正を適用する(make fix-libdave でも実行可能):
.\fix-libdave.ps1Ensure you have gcc and opus library installed:
sudo apt-get install gcc libopus-dev # For Debian/Ubuntu
# or
sudo yum install gcc opus-devel # For CentOS/RHELThen build:
go build -o consonanceOr using Makefile:
make build-linuxInstall opus library using Homebrew:
brew install opusThen build:
go build -o consonanceOr using Makefile:
make build-macNo manual configuration required! Just run the bot:
./consonance.exe # or ./consonance on Linux/macOSOn first run, the bot will:
- Automatically create
config.yamlif it doesn't exist - Prompt you to enter your Discord bot token
- Save your token to
config.yaml - Prompt you to select an audio device
- Optionally save the device as default
Example first run:
=== Discord Bot Token Required ===
Your Discord bot token is not configured.
To get your bot token:
1. Go to https://discord.com/developers/applications
2. Select your application (or create a new one)
3. Navigate to the 'Bot' section
4. Click 'Reset Token' or 'Copy' to get your token
5. Make sure to enable 'MESSAGE CONTENT INTENT' under Privileged Gateway Intents
Paste your Discord bot token here: [YOUR_TOKEN]
✓ Discord token saved to config.yaml
=== Select Audio Device ===
Available audio devices for loopback capture:
[1] Speakers (Realtek High Definition Audio) (Default)
[2] Line (Yamaha SYNCROOM Driver)
Enter device number: 2
✓ Selected: Line (Yamaha SYNCROOM Driver)
Save this device as default in config.yaml? (y/n): y
✓ Device saved to config.yaml
If you prefer to manually configure, copy config.yaml.example to config.yaml:
cp config.yaml.example config.yamlMinimum required configuration:
discord_token: "YOUR_BOT_TOKEN_HERE"To automatically join a voice channel on startup:
discord_token: "YOUR_BOT_TOKEN_HERE"
guild_id: "0987654321" # Your Discord server (guild) ID
channel_id: "1234567890" # Voice channel to auto-join- Go to Discord Developer Portal
- Create a new application or select an existing one
- Navigate to the "Bot" section
- Click "Reset Token" and copy your bot token
- In the Discord Developer Portal, go to your application
- Navigate to the "Bot" section
- Scroll down to "Privileged Gateway Intents"
- Enable the following intents:
- ✅ MESSAGE CONTENT INTENT (required for commands)
- ✅ SERVER MEMBERS INTENT (recommended)
- ✅ PRESENCE INTENT (recommended)
- Click "Save Changes"
Without these intents enabled, you'll see an error like:
websocket: close 4004: Authentication failed.
The bot supports two ways to select an audio device:
-
Interactive Selection (Recommended): Leave
audio_device_nameempty or commented out inconfig.yaml. When you start the bot:- You'll see a numbered list of available devices
- Enter the device number to select it
- Optionally save your selection to
config.yamlfor future use
=== Select Audio Device === Available audio devices for loopback capture: [1] Speakers (Realtek High Definition Audio) (Default) [2] Line (Yamaha SYNCROOM Driver) [3] Headphones (USB Audio) Enter device number: 2 ✓ Selected: Line (Yamaha SYNCROOM Driver) Save this device as default in config.yaml? (y/n): y ✓ Device saved to config.yaml -
Pre-configured Device: Set
audio_device_nameinconfig.yamlto use a specific device automatically:audio_device_name: "Line (Yamaha SYNCROOM Driver)"
Simply run the executable:
./consonance.exe # on Windows
./consonance # on Linux/macOSFirst-time users: The bot will guide you through:
- Creating
config.yaml(if it doesn't exist) - Entering your Discord bot token
- Selecting an audio device
Subsequent runs: The bot will use your saved configuration and start immediately.
The bot will connect to Discord. You can then:
- Use Discord chat commands to join/leave voice channels (see below)
- Or, if
guild_idandchannel_idare set inconfig.yaml, it will auto-join that channel
You can control the bot by mentioning it in any text channel on your Discord server.
No configuration required! Just mention the bot with commands:
@YourBot join #channel-name
Or search by channel name (without #):
@YourBot join channel-name
@YourBot leave
@YourBot status
Shows current connection status and streaming information.
@YourBot help
Shows available commands.
- The bot captures system audio (loopback) from your computer
- It encodes the audio to Opus format
- The audio is streamed to the Discord voice channel in real-time
- You can switch channels on-the-fly using Discord commands without restarting the bot
- Make sure your Discord bot has the necessary permissions to join voice channels
- Required bot permissions:
Connect,Speak,Read Messages,Send Messages - The bot uses loopback audio capture to stream system audio
ConsoNance uses a simple version management system with the format YY.MM.minor (e.g., 26.03.0):
- YY: Year (2-digit)
- MM: Month (2-digit)
- minor: Minor version number within the month
To update the version:
-
Edit the
Versionconstant inversion.go:const Version = "26.03.0" // Update this value
-
The version will be displayed:
- On application startup (in logs and console)
- In the
@Bot helpcommand response
| コマンド | 説明 |
|---|---|
make build-win |
Windows 向けビルド + libdave.dll コピー |
make fix-libdave |
libdave クロス CRT ヒープ修正を適用 |
make dist |
配布用 zip を生成 (exe + dll + ライセンス) |
make clean |
ビルド成果物を削除 |
配布に必要なファイル:
| ファイル | 説明 |
|---|---|
ConsoNance.exe |
本体 |
libdave.dll |
Discord DAVE 暗号化ライブラリ (MIT License) |
LICENSE |
ConsoNance の GPL v3 ライセンス |
NOTICE |
サードパーティライセンス表示 |
make dist で ConsoNance-vXX.XX.X-windows-x64.zip が自動生成される。
| ライブラリ | 用途 | リンク方式 |
|---|---|---|
| disgoorg/disgo v0.19.2 | Discord API (DAVE 対応) | 静的 |
| discord/libdave v1.1.1 | DAVE E2EE 暗号化 | 動的 (DLL) |
| gen2brain/malgo | オーディオキャプチャ | 静的 |
| layeh.com/gopus | Opus エンコード | 静的 |
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- ✅ You can use this software freely
- ✅ You can modify the source code
- ✅ You can distribute modified versions
⚠️ Any derivative work must also be licensed under GPL v3.0⚠️ You must disclose the source code of derivative works⚠️ You must include the original copyright and license notices
Copyright (C) 2025 Kazuki F.