TopazBot - RTSP Discord Music bot for TopazChat
๐ Overview
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.
โจ Key Features
- ๐ง High Quality: Stereo, high-fidelity, low-latency stream playback.
- ๐ Secure: Safe communication with Discord signature verification.
- ๐ Multi-format Support: Flexible stream processing with ffmpeg.
๐ About TopazChat
๐ Details
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.
๐ฌ Community
- TopazChat Discord Server
Join: https://discord.com/invite/fCMcJ8A
๐ Quick Start
There are two ways to get started with TopazBot.
1. Use the Public Bot
This is the easiest way. You can add the bot to your Discord server using the link below:
2. Self-Hosting
You can host the bot on your own server.
๐ Prerequisites
- Linux Server
- FFmpeg (RTSP-enabled)
- Node.js 22.x
- npm or yarn
- Discord Bot Token
- TopazChat Stream
๐ฆ Dependencies
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.
๐ง Debian or Ubuntu
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
๐ ๏ธ Installation
# 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 variables
โ๏ธ Configuration
Set the following environment variable in your .env
file:
DISCORD_TOKEN=your_discord_bot_token
๐ Deployment
# 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 -- start
๐ฎ Command List
TopazBot supports the following slash commands.
โถ๏ธ /play
- 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.
๐ /resync
- Description: Attempts to reconnect if the connection is unstable or the stream is interrupted.
- Usage:
/resync
โน๏ธ /stop
- Description: Stops the current stream playback and disconnects from the voice channel.
- Usage:
/stop
๐ Legal
๐๏ธ Architecture
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
๐ง Tech Stack
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 |
๐งช Development
๐ Scripts
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 |
๐ Debugging
# Start local development server
npm run dev
# Run tests
npm test
# Generate coverage report
npm run test:coverage
The coverage report can be viewed at coverage
๐ Code structure
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
๐ค Contributing to TopazBot
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.
โค๏ธ Donations
๐ป TopazBot
Please consider donating to help maintain the public TopazBot server.
- TopazBot GitHub Sponsors
๐ TopazChat
The developer of TopazChat, Hirotoshi Yoshitaka, is seeking donations to cover server maintenance and data transfer costs.
- TopazChat FANBOX
๐ Credits
๐ป TopazBot
- Aoi Emerauda @emerauda
๐ TopazChat
- Hirotoshi Yoshitaka @TyounanMOTI TopazChat Developer
๐ License
This project is released under the MIT License. See the LICENSE file for details.
๐ฅ Team
๐ Support
- ๐ Bug Reports: Issues
- ๐ก Feature Requests: Discussions
- ๐ง Contact: aoi@emerauda.com