Consonance <-> Discord
Audio Stream Bot for Discord
WIP
- Go 1.16 or later
- CGO-enabled environment
- C compiler (gcc)
- Opus library
To build on Windows, you need to install MSYS2 and required packages:
-
Install MSYS2
- Download the installer from https://www.msys2.org/
- Run the installer and follow the default installation (installs to
C:\msys64)
-
Update MSYS2
- Open "MSYS2 MSYS" from the Start Menu
- Run the following command:
pacman -Syu
- The terminal will close after the update. Open "MSYS2 MSYS" again and run:
pacman -Su
-
Install required packages
- Open "MSYS2 MinGW64" from the Start Menu
- Run the following command:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-opus
-
Set environment variables
- In PowerShell, add MinGW64 to your PATH:
$env:PATH += ";C:\msys64\mingw64\bin" $env:CGO_ENABLED = "1"
- In PowerShell, add MinGW64 to your PATH:
-
Build the application
go build -o consonance-win.exe
Or using Makefile:
make build-windows
Ensure 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., 25.12.1):
- 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 = "25.12.2" // Update this value
-
The version will be displayed:
- On application startup (in logs and console)
- In the
@Bot helpcommand response
The project includes several build targets in the Makefile:
make build-win: Build for Windows (PowerShell)make build-linux: Build for Linuxmake build-mac: Build for macOS
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.