Skip to content
Advertisement

Discord js Voice – AudioResource

In the DiscordJs Voice documentation it is stated that AudioPlayer is reusable, so I can create only one instance of it and use it all the time. However, I did not find any mentions about reusability of AudioResource. For example, I want to play the first song in the array:

resource = createAudioResource(playlist[0]);
player.play(resource);

But if I want to create queue by adding more songs to the playlist, what should I do with the resource? Declare another resource1? Or can I do something like:

resource.read(playlist[1])

Advertisement

Answer

Audio resources are not reusable. You will need to simply make another resource

You can however reuse the variable, not the resource

resource = createAudioResource(playlist[1])
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement