Repository navigation
Contributing
Thanks for helping to make Beatra better. Fixes, new translations, tests and well-described bug reports are all welcome.
- Fork umutxyp/MusicBot on GitHub and clone your fork.
- Install Node.js 22.12 or newer.
- Create a test bot in the Discord Developer Portal and a test server, so you never experiment on a live bot.
- Make a
.envwith the token and your test server.GUILD_IDmakes command changes appear in that server right away:DISCORD_TOKEN=your_test_bot_token GUILD_ID=your_test_server_id DEBUG=true
- Start it with
npm start. The startup check installs the packages and downloads yt-dlp and ffmpeg.
| Command | What it does |
|---|---|
npm start |
Startup check, then the bot under the sharding manager |
npm test |
Runs every test in test/*.test.js with Node's built-in test runner (node --test) |
npm run check |
Syntax check of every .js file and a JSON check of every file in languages/, without starting the bot |
npm run deploy |
Forces slash command registration (needs DISCORD_TOKEN and CLIENT_ID in .env) |
npm run shard |
Same as npm start (kept for older start scripts) |
postinstall |
Runs by itself after npm install and downloads yt-dlp and ffmpeg (scripts/install-binaries.js). A failure is only a warning: the startup check tries again |
The audio pipeline has an end-to-end test that runs the real yt-dlp and ffmpeg. It is skipped unless you point YTDLP_E2E at a real yt-dlp program:
YTDLP_E2E=$(which yt-dlp) npm testPlease run npm test and npm run check before opening a pull request.
index.js Entry point: startup check, then the sharding manager
src/
setup/ Startup check (bootstrap needs no npm packages), launcher
bot.js One shard: Discord client, events, graceful shutdown
config.js Reads .env
deploy.js Slash command registration (only when commands changed)
commands/ Slash commands
handlers/ Interaction router and permission checks
music/ DisTube setup, YouTube extractor, yt-dlp runner, audio relay, sessions, lyrics
ui/views.js Components V2 layouts
core/ Logger, i18n, cache, JSON store, formatting, yt-dlp/ffmpeg download
languages/ Translations
test/ Tests
bin/ yt-dlp program folder (downloaded and updated automatically, git-ignored)
data/ Settings and saved queues (created automatically, git-ignored)
Follow what the existing code does:
-
CommonJS modules with
'use strict';at the top, andnode:prefixes for built-ins (require('node:fs')). - 4 spaces for indentation, single quotes, semicolons.
- Short JSDoc comments that explain why, above functions that need it.
- No new dependencies unless they are really needed. The startup files in
src/setup/(bootstrap.js,report.js) must keep working with Node built-ins only, because they run beforenpm install. - Texts that users see come from the language files through
t('key'), so they can be translated. - Add or update tests in
test/for behaviour you change.
- Create a file in
src/commands/, for examplesrc/commands/example.js. Files starting with_are helpers and are not loaded as commands. - Export a
category(playback,queueorsettings, which decides the order in/help),dataandexecute. Use thecommand()helper from_shared.js, which makes the command server-only and adds translated descriptions:'use strict'; const { command, queueAction } = require('./_shared'); const actions = require('../music/actions'); module.exports = { category: 'playback', data: command('example', 'What the command does'), execute(interaction, ctx) { return queueAction(interaction, ctx, (queue, t) => actions.pause(queue, t)); }, };
queueActionruns the usual voice checks first (user in the bot's channel, music playing) and replies with the result. - Optional: add
commands.example.descriptionto the language files. It is used for the translated description in Discord and in/help; without it the English text fromcommand()is shown. - Restart the bot. It notices the new command and registers it; with
GUILD_IDset it appears in your test server at once.
Command names must be unique; the loader stops with Duplicate command name otherwise.
- Copy
languages/en.jsontolanguages/<code>.jsonand translate the values. Keep the keys and the{placeholders}exactly as they are. - Set
"language": { "name": "...", "code": "<code>" }at the top. The name is shown in the/languagemenu. - To follow Discord's language setting automatically, add the Discord locale to
DISCORD_LOCALESinsrc/core/i18n.js. - Run
npm run checkto make sure the JSON is valid.
Good to know: missing keys fall back to English, and emoji are stripped from translations so the panels look clean. The /language menu can show up to 25 languages.
Open an issue on GitHub Issues and include:
- What you did, what you expected, and what happened instead.
- The bot version (
versioninpackage.json), your operating system andnode -v. - The startup check output and the console log around the problem, ideally with
DEBUG=true.
Warning: Before you paste anything, remove your token, proxy passwords and anything from
cookies.txt. Never attach your.envorcookies.txt.
Please do not open a public issue for a security problem. Use GitHub's private reporting instead: Report a vulnerability. Describe the problem and how to reproduce it.
If your bot token ever leaks, press Reset Token in the Discord Developer Portal right away, so the old token stops working.
Beatra is released under the MIT License. By contributing you agree that your contribution is released under the same license.
Beatra Music Bot (umutxyp/MusicBot) · MIT License · by Umut Bayraktar · Codeshare
Start here
Using the bot
Running it
Project