Is it possible to modify the player?

I'm looking to add my own custom function for the player.play(); function and was wondering it was possible to pass it as an option, or would I have to edit the code directly to include this change? If you're confused, a notable example would be as follows, this is current the Shoukaku Lavalink Wrapper which does allow you to pass in your own Rest Client or Player. This question would also apply to the Rest Client, since the current port of my bot loads information from Spotify instead of through Lavalink and passes it to the player.
class SpotifyPlayer extends Player {
async playTrack() {
// code here
return super.playTrack(playable)
}
class SpotifyPlayer extends Player {
async playTrack() {
// code here
return super.playTrack(playable)
}
1 Reply
1Lucas1.apk
1Lucas1.apk•2y ago
Hello, well I'll make an example for you to put your function
const { MoonlinkPlayer } = require('moonlink.js')
class NewPlayer extends MoonlinkPlayer {
constructor(data, manager, map, rest) {
super(data, manager, map, rest)
}
your_custom_method() {
/**/
}
}
const { MoonlinkPlayer } = require('moonlink.js')
class NewPlayer extends MoonlinkPlayer {
constructor(data, manager, map, rest) {
super(data, manager, map, rest)
}
your_custom_method() {
/**/
}
}
In options when creating the class you use custom parameter new MoonlinkManager(/nodes/, { custom: { player: NewPlayer } }, /spayload/)

Did you find this page helpful?