Skip to content

DisTube Module (Music)

The DisTube Module (@zumito-team/distube-module) brings full music playback capabilities to your bot via the DisTube library. It supports YouTube, Spotify, SoundCloud, BandLab, and VK, and integrates with the User Panel for a queue management interface.

Terminal window
npm install @zumito-team/distube-module

Add to your zumito.config.ts:

bundles: ['@zumito-team/distube-module']

The core service that wraps a DisTube instance with plugins for multiple platforms:

PlatformPlugin
YouTube@distube/youtube
Spotify@distube/spotify
SoundCloud@distube/soundcloud
BandLab@distube/bandlab
VK Musicdistube-vk-music-plugin

Access the DisTube instance directly:

const music = ServiceContainer.getService('MusicService');
music.distube.play(voiceChannel, query);

All commands are in the music category:

CommandDescription
playPlay a song/playlist in your voice channel. Generates a “now playing” image card.
skipSkip the current song.
queueShow the current song queue.
stopStop playback and clear the queue.
pausePause playback.
resumeResume paused playback.
nowplayingShow currently playing song info.
volumeAdjust music volume.
shuffleShuffle the queue.
loopToggle loop mode.
seekJump to a specific position in the song.
removeRemove a specific song from the queue.
leaveBot leaves the voice channel.
joinBot joins your voice channel.
autoplayToggle autoplay.
forwardForward in the current song.
rewindRewind the current song.
moveMove a song in the queue.
playskipPlay a song and skip to it immediately.
playtopAdd a song to the top of the queue.
filtersApply audio filters (nightcore, bassboost, etc.).
bassboostToggle bass boost effect.

The module registers a Music page in the User Panel sidebar at /panel/:guildId/music. This page shows:

  • Current song with progress
  • Full queue list
  • Playback controls

The MusicService handles these DisTube events:

EventBehavior
PLAY_SONGSends a message to the text channel.
ADD_SONGConfirms the song was added to queue.
FFMPEG_DEBUGLogs ffmpeg debug output.
ERRORLogs detailed DisTube error information.

The module uses these environment variables implicitly:

  • FFMPEG_PATH — Set automatically via ffmpeg-static. No manual config needed.

Translations are defined in:

  • translations/en.json
  • translations/es.json

You can access the DisTube instance and add your own plugins or custom extractors:

import { ServiceContainer } from 'zumito-framework';
const music = ServiceContainer.getService('MusicService');
const distube = music.distube;
// Add a custom extractor plugin
distube.extractors.push(myCustomExtractor);

The play command uses CanvasUtils to generate image cards. You can replace the card generation by extending or modifying the command:

class CustomPlayCommand extends Command {
// Override the execute method to use your own card design
async execute(params: CommandParameters) {
const music = ServiceContainer.getService('MusicService');
// ... custom logic ...
}
}

The module declares requeriments.services: ['UserPanelNavigationService'] and registers its music page under the User Panel’s dashboard section. Any module can follow this pattern to add pages to the user panel.

  • distube — Core music library.
  • @distube/youtube, @distube/spotify, @distube/soundcloud, @distube/bandlab, distube-vk-music-plugin — Platform plugins.
  • @zumito-team/canvas-module — For “now playing” cards.
  • @zumito-team/user-panel-module — For queue page in user panel.
  • @snazzah/davey — Lyrics support.
  • ejs — Template rendering.
  • ffmpeg-static — FFmpeg binary.
  • opusscript — Opus audio codec.
  • discord.js (peer) — Discord client.
  • zumito-framework