TopazBot is a high-quality, low-latency Discord music bot that utilizes TopazChat's RTSP stream. It runs on servers like Linux and provides streamed audio to your Discord server.
Attention!!
"TopazBot" is under the MIT license, but "TopazChat" is not for commercial use.
- 🧠 High Quality: Stereo, high-fidelity, low-latency stream playback.
- 🔒 Secure: Safe communication with Discord signature verification.
- 🌐 Multi-format Support: Flexible stream processing with ffmpeg.
TopazChat is a high-quality, low-latency RTSP server. It is free for personal use.
The costs for TopazChat are covered by the developer, Hirotoshi Yoshitaka @TyounanMOTI.
Please consider donating to help with server maintenance and data transfer costs for audio/video streaming! → FANBOX
All sponsors of TopazChat are listed in SPONSORS.txt.
- TopazChat Discord Server
Join: https://discord.com/invite/fCMcJ8A
There are two ways to get started with TopazBot.
This is the easiest way. You can add the bot to your Discord server using the link below:
You can host the bot on your own server.
- Linux Server
- FFmpeg (RTSP-enabled)
- Node.js 22.x
- npm or yarn
- Discord Bot Token
- TopazChat Stream
This library requires one dependency from each of the categories below to support various platforms.
The dependencies are listed in order of performance preference.
If you cannot install one of the options, try installing another.
node & npm:
node: >=22npm: >=6
discord.js (npm install)
discord.js: ^14.21.0
@discordjs/voice (npm install):
@discordjs/voice: ^0.18.0
@discordjs/opus (npm install):
@discordjs/opus: "^0.10.0"
Encryption Libraries (npm install):
sodium-native: ^5.0.6
Opus Libraries (npm install):
@discordjs/opus: ^0.10.0
FFmpeg:
FFmpeg(Please install on your server, e.g.,apt install ffmpeg)
pm2 (npm install): [Optional]
pm2
# Clone the repository
git clone https://github.com/emerauda/TopazBot.git topazbot
cd topazbot
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit the .env file and set the required environment variablesSet the following environment variables in your .env file:
# Discord Bot Configuration
DISCORD_TOKEN=your_discord_bot_token
# RTSP Server Configuration (optional)
# Default: rtsp://topaz.chat/live
RTSP_SERVER_URL=rtsp://topaz.chat/live
# Alternative examples:
# RTSP_SERVER_URL=rtsp://example.com/stream
# RTSP_SERVER_URL=rtsp://192.168.1.100:8554/liveConfiguration Options:
DISCORD_TOKEN: Your Discord bot token (required)RTSP_SERVER_URL: RTSP server base URL (optional, defaults tortsp://topaz.chat/live)
When using the bot, streams will be accessed as ${RTSP_SERVER_URL}/${streamkey}.
# Build
npm run build
# Start
npm run start
# Register commands
npm run register
# Start the program using pm2
npm i pm2 -g
pm2 start npm -n TopazBot -- startTopazBot supports the following slash commands.
- Description: Plays the RTSP stream from TopazChat using the specified stream key.
- Usage:
/play StreamKey: <your_stream_key> - Parameters:
StreamKey(required): Your TopazChat stream key.
- Description: Attempts to reconnect if the connection is unstable or the stream is interrupted.
- Usage:
/resync
- Description: Stops the current stream playback and disconnects from the voice channel.
- Usage:
/stop
graph TD
subgraph "Discord Server"
User
DiscordVoiceChannel[Discord Voice Channel]
end
subgraph "Your Server (VPS)"
TopazBot
FFmpeg
end
subgraph "TopazChat Server"
TopazChat
end
User -- "/play" --> TopazBot
TopazBot -- "RTSP Stream Request" --> TopazChat
TopazChat -- "RTSP Stream" --> FFmpeg
FFmpeg -- "Opus Audio" --> TopazBot
TopazBot -- "Sends Audio" --> DiscordVoiceChannel
| Category | Technology | Version |
|---|---|---|
| Language | TypeScript | ^5.8.3 |
| Runtime | Node.js | >=22.x |
| Framework | discord.js | ^14.21.0 |
| Audio Processing | @discordjs/voice | ^0.18.0 |
| Media Processing | FFmpeg | - |
| RTSP Server | TopazChat | - |
| Opus Library | @discordjs/opus | ^0.10.0 |
| Encryption | sodium-native | ^5.0.6 |
| Package Manager | npm | >=6 |
| Testing | Jest | ^30.0.3 |
| Linter | ESLint | ^9.30.1 |
| Formatter | Prettier | ^3.6.2 |
| Command | Description |
|---|---|
npm run build |
Build TypeScript |
npm run dev |
Start development server |
npm run register |
Register Discord commands |
npm run lint |
Run type checking |
npm run lint:fix |
Run type fixing |
npm run format |
Apply code formatting |
npm run format:check |
Check code formatting |
npm run test |
Run tests |
npm run test:watch |
Run tests in watch mode |
npm run test:coverage |
Run tests with coverage |
# Start local development server
npm run dev
# Run tests
npm test
# Generate coverage report
npm run test:coverageThe coverage report can be viewed at coverage
The code for this bot is specific to TopazChat.
Here is the code I used for reference: discordjs-japan/Playing Audio (in Japanese)
Created by Discord.js Japan user Group
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please read our Contributing Guidelines for more details on the process and what we expect.
Please consider donating to help maintain the public TopazBot server.
- TopazBot GitHub Sponsors
The developer of TopazChat, Hirotoshi Yoshitaka, is seeking donations to cover server maintenance and data transfer costs.
- TopazChat FANBOX
- Aoi Emerauda @emerauda
- Hirotoshi Yoshitaka @TyounanMOTI TopazChat Developer
This project is released under the MIT License. See the LICENSE file for details.
- 🐛 Bug Reports: Issues
- 💡 Feature Requests: Discussions
- 📧 Contact: [email protected]
