Migrating to v7
Learn how to migrate your existing discord-player v6 code to v7
Discord Player v7 is a major release with some breaking changes. This guide will help you migrate your existing v6 code to v7.
Key Changes
VoiceReceiverNode
Removed
In v7, we have removed VoiceReceiverNode
from the framework. This means that any codebase that uses VoiceReceiverNode
api will need to be updated.
We no longer support this feature at the core level. If you want to use voice receiving functionality, please follow @discordjs/voice example. This was done to make the library more lightweight and focused on the core features.
Mediaplex is now preinstalled
In v7, mediaplex comes preinstalled with the library. This means you don't need to install opus libraries such as @discordjs/opus
or opusscript
separately. Mediaplex is maintained by the discord-player team and is a drop-in replacement for @discordjs/opus
.
YoutubeExtractor
Removed
In v7, we have removed YoutubeExtractor
from the framework. This means that any codebase that uses YoutubeExtractor
api will need to be updated.
YouTube playback is officially discontinued due to the frequent breakage of YouTube extraction libraries. Discord Player still comes with query detection utility for YouTube (i.e. detecting if the given query is a youtube link or not) but it does not support playback or metadata extraction.
lyricsExtractor
Removed
In v7, we have removed lyricsExtractor
from the framework. This means that any codebase that uses lyricsExtractor
api will need to be updated. This was done in favor of the new lyrics api that is more flexible and even supports synced lyrics. See Getting Lyrics for more information.
player.extractors.loadDefault
removed
In v7, we have removed player.extractors.loadDefault
from the framework. This means that any codebase that uses player.extractors.loadDefault
api will need to be updated. This was done to make loading extractors more explicit and to avoid any confusion. The new alternative method to player.extractors.loadDefault
is
IP Rotator Removed
In v7, we have removed the IP rotator from the framework. This means that any codebase that uses the IP rotator will need to be updated. This was done to make the library more lightweight and focused on the core features. The extractors may implement their own IP rotator if needed.
tweetnacl support removed
In v7, tweetnacl
as encryption library is not supported. This was done due to the voice encryption requirement imposed by Discord.
GuildQueueEvent
no longer provides camelCase
enums
In v7, GuildQueueEvent
no longer provides camelCase
enums. This means that any codebase that uses GuildQueueEvent
enums will need to be updated. The enums are now provided in PascalCase
format. For example, GuildQueueEvent.playerStart
is now GuildQueueEvent.PlayerStart
.
Player
is no longer a singleton
In v7, Player
is no longer a singleton. This means that you can create multiple instances of Player
and manage them separately. Hooks should still behave as usual, but creating a new instance will override the hooks binding and hooks will now point to latest instance. If you want to use hooks with multiple instances independently, you have to utilize the hooks context api.
Assuming you have a command handler that looks something like this:
You will need to wrap command.execute
in a player context provider like this:
You can now use hooks in your command like this:
Before
After
Discord Player will automatically resolve the guild from the context.
The hooks will not work outside the context scope. If you want to use hooks outside the context scope, you have to provide the arguments manually.
Passing arguments to hooks inside a context will ignore the context and use the provided arguments instead. This may cause unexpected issues when using multiple instances of Player
.
See Using Hooks for more information.
queue.node.playRaw
method removed
The queue.node.playRaw
method allowed you to play a custom audio resource. This method has been removed in v7. You can now directly use player.play
to play a custom audio resource.