aliana-musicard-discord-bot-example
v1.0.0
Published
Example Discord music bot using aliana-musicard and aliana-client
Downloads
5
Maintainers
Readme
Discord Music Bot Example
This example demonstrates how to create a Discord music bot using aliana-musicard and aliana-client.
Features
- 🎵 Play music from YouTube
- 🎨 Automatically generates beautiful music cards when tracks play
- 🔄 Queue system with autoplay support
- ⚡ Uses Lavalink v4 for high-quality audio
Installation
npm installSetup
- Create a Discord bot at https://discord.com/developers/applications
- Enable these intents in the Bot section:
- Server Members Intent
- Message Content Intent
- Copy your bot token
- Set your environment variables:
export DISCORD_TOKEN="your-bot-token-here"
export CLIENT_ID="your-bot-client-id"Or create a .env file:
DISCORD_TOKEN=your-bot-token-here
CLIENT_ID=your-bot-client-idRun
npm startFor development with auto-reload:
npm run devCommands
Music Playback
!play <song>- Play a song or add to queue!stop- Stop playback and clear queue!skip- Skip current track!pause- Pause playback!resume- Resume playback!queue- Show current queue!npor!nowplaying- Show current track with music card
Settings
!autoplay- Toggle autoplay (continues with similar songs)!help- Show all commands
How It Works
Music Cards
When a track starts playing, the bot automatically:
- Generates a beautiful music card using
aliana-musicard - Randomly selects from 8 available themes
- Displays track info (title, artist, album art)
- Sends it as an embed in Discord
Lavalink Integration
The bot uses aliana-client to connect to a public Lavalink server:
- Host:
lava-v3.ajieblogs.eu.org - Port:
80 - No setup required - works out of the box!
Customization
Change Themes
Edit the themes array in index.js:
const themes = ['cherry-blossom', 'cyberpunk-anime', 'neon-grid', 'space'];Available themes:
cherry-blossom(Anime)cyberpunk-anime(Anime)forest-nature(Nature)ocean-sunset(Nature)minecraft-overworld(Minecraft)minecraft-nether(Minecraft)neon-grid(Futuristic)space(Futuristic)
Use Your Own Lavalink Server
Update the nodes configuration:
nodes: [
{
authorization: "your-password",
host: "your-server.com",
port: 2333,
identifier: "My Node",
secure: false, // set to true for HTTPS
},
]Local Development (Unpublished Package)
If you're testing the aliana-musicard package before it's published to npm:
Option 1: File Path (Already Configured)
The package.json already uses a file path:
{
"dependencies": {
"aliana-musicard": "file:../../server/musicard"
}
}Just build the package first:
cd ../../server/musicard
npm run build
cd ../../examples/discord-bot
npm install
npm startOption 2: Using npm link
# From the musicard package directory
cd server/musicard
npm run build
npm link
# From the example bot directory
cd examples/discord-bot
npm link aliana-musicard
npm install
npm startTroubleshooting
Bot doesn't connect to voice
- Ensure bot has
GuildVoiceStatesintent enabled - Check Lavalink server is running and accessible
- Verify bot has permissions to join voice channels
Music cards not generating
- Make sure
@napi-rs/canvasis installed correctly - Check album artwork URLs are accessible
- Verify theme names match available themes
Commands not working
- Enable
MessageContentintent in Discord Developer Portal - Ensure bot has permissions to read and send messages
Links
License
MIT © Npg
