What are Extractors?
Extractors are modular components in Discord Player that handle fetching metadata and streaming audio from various sources. Each extractor is responsible for:- Validating queries - Determining if a query belongs to their service
- Extracting metadata - Fetching track information (title, author, duration, etc.)
- Streaming audio - Providing playable audio streams
- Bridging - Converting metadata from one source to a streamable format from another
Extractors use a priority system where higher priority extractors are executed first. The default priority is
1, but you can customize it when creating custom extractors.How Extractors Work
Execution Flow
When you search for a track, Discord Player:- Runs all registered extractors sorted by priority (highest first)
- Validates the query against each extractor using
validate() - Handles the query with the first matching extractor using
handle() - Returns track metadata as
Trackobjects - Streams audio when needed using
stream()
Bridging System
Some extractors (like Spotify and Apple Music) only provide metadata, not audio streams. Discord Player uses a bridging system to automatically find streamable versions:bridge() method:
Loading Extractors
Load Default Extractors
Load Specific Extractors
Load with Options
Managing Extractors
Register Individual Extractor
Unregister Extractor
Check Extractor Status
Block Extractors
You can prevent specific extractors from executing:Extractor Events
Listen to extractor lifecycle events:Protocols
Extractors can define custom protocols for search shortcuts:Protocols are defined in each extractor’s
protocols property and are automatically registered during activation.Query Types
Discord Player uses query types to route queries to the appropriate extractor:| Query Type | Description | Example |
|---|---|---|
SPOTIFY_SONG | Spotify track | https://open.spotify.com/track/... |
SPOTIFY_PLAYLIST | Spotify playlist | https://open.spotify.com/playlist/... |
SPOTIFY_ALBUM | Spotify album | https://open.spotify.com/album/... |
SPOTIFY_SEARCH | Spotify search | spsearch:query |
SOUNDCLOUD_TRACK | SoundCloud track | https://soundcloud.com/... |
SOUNDCLOUD_PLAYLIST | SoundCloud playlist | SoundCloud set URL |
SOUNDCLOUD_SEARCH | SoundCloud search | scsearch:query |
APPLE_MUSIC_SONG | Apple Music song | https://music.apple.com/... |
APPLE_MUSIC_ALBUM | Apple Music album | Apple Music album URL |
APPLE_MUSIC_PLAYLIST | Apple Music playlist | Apple Music playlist URL |
VIMEO | Vimeo video | https://vimeo.com/... |
REVERBNATION | Reverbnation track | https://reverbnation.com/... |
ARBITRARY | Direct URL | Any direct audio URL |
FILE | Local file | /path/to/file.mp3 |
AUTO | Auto-detect | Let Discord Player detect |
Best Practices
Load extractors once
Load extractors during bot initialization, not on every command.
Use loadMulti for batches
Use
loadMulti() instead of multiple register() calls for better performance.Handle extractor errors
Listen to the
error event to catch and log extractor failures.Set appropriate priorities
Custom extractors should have priorities based on their reliability and speed.
Next Steps
Default Extractors
Learn about built-in extractors and their configuration
Custom Extractors
Create your own extractors for custom sources