Extractors API
Learn how to create custom extractors for discord-player
Extractors are an extension to discord-player. It has the ability to alter search results and streams.
Official Extractors
Discord Player supports the following sources using the following sources with the help of @discord-player/extractor:
- Local file (You must set the search engine to
QueryType.FILE
in order to play local files, backed byattachment extractor
) - Raw attachments (backed by
attachment extractor
) - Spotify (backed by
spotify extractor
) - Apple Music (backed by
appleMusic extractor
) - Vimeo (backed by
vimeo extractor
) - Reverbnation (backed by
reverbnation extractor
) - SoundCloud (backed by
soundcloud extractor
)
If you need to extend this functionality and add support for more sources, you can build your own extractor with the help of extractors api.
Extractor Anatomy
Loading Extractor
Do not instantiate the extractor class directly. Always use player.extractors.register
method to load your
extractor. Discord Player will instantiate the extractor for you.
Search Engine Behavior
Discord Player search engine can be set to values such as QueryType.SOUNDCLOUD_SEARCH
to force that particular action. But since we are using custom extractor, we may not have appropriate value for our source. In order to force trigger our extractor, we can set the value of searchEngine
to ext:my-extractor-id
. Example:
This will force discord-player to execute the action using MyExtractor
only.