Closed sawa-ko closed 3 years ago
What kind of management
.getPlayer()
method and avoid having many active listeners in different commands.Possible to be considered on next
but definitely will not ship in current v1, though I'm not sure how you are not being able to do everything in one place, are you not extending, or making a queue system around the player?
When I say in one place I mean to manage a queue system for example from a service class, and not to depend on any command.
Sometimes I get an error that says Shoukaku reached max listeners and things like that, that's why I give that idea. That happens by having listeners in commands.
When I say in one place I mean to manage a queue system for example from a service class, and not to depend on any command.
Sometimes I get an error that says Shoukaku reached max listeners and things like that, that's why I give that idea. That happens by having listeners in commands.
I usually just store shoukaku player as a property on my own player, then attach listeners on the constructor or have a specific init method that would only be executed once, so you wont re-add any listeners once added
Do you have any examples of how to implement that in that way you mention?
But also, it would be nice if those listeners were available in the client, I hope that in the future you can put it.
// create a play function that accepts an existing player
async play(player) {
const song = await player.voiceConnection.node.resolve('something');
await player.playTrack(song);
}
// create a player variable, where in we will attach listeners on it once only
const player = await node.joinVoiceChannel();
// use the play function to play your queue, instead of attaching listeners per play function
player.on('end', () => play(player));
// execute play for the first time
play();
Yes I do, but there are times when I get the error I mentioned even when using a method like that.
Yes I do, but there are times when I get the error I mentioned even when using a method like that.
Are you sure you are not re attaching listeners? the ideal scenario is to ensure you only attach the listeners at once
Yes, I make sure of that but sometimes I get that error, that's why I suggested this issue
I can consider this, but definitely will not ship in current 1.6.x, if considered, expect this to be on 2.x.x, and most likely is not a Shoukaku issue, because as far as I know, me, and other users that use this lib don't encounter this particular issue
Okay, thanks for adding this feature in the future that may be useful for others as well
Check latest next-branch commits, new events on Shoukaku Class have been added, named playerReady
and playerDestroy
It would be nice to have an event in the client called
playerStart
andplayerEnd
, and to be executed every time a guild player starts or ended.I say this idea in order to better manage the control of players from one place.
Example: