I'm using @discordjs/voice for a bot. When I try to change the audio volume of a resource, no matter if it's while the resource is being played currently or if I do it before playing it, it doesn't seem to have any effect.
My code for creating the resource looks like this:
const stream = ytdl(url, {
filter: "audioonly",
format: "mp3",
highWaterMark: 1 << 62,
liveBuffer: 1 << 62,
dlChunkSize: 0,
bitrate: 128,
quality: "lowestaudio"
})
const resource = createAudioResource(stream, {inlineVolume: true});
And for changing the volume before playing:
resource.volume.setVolume(audioVolume);
audioPlayer.play(resource);
I've tried audioVolume
values between 0.0-1.0 as well as between 0-100 but no matter the value, the audio volume stayed exactly the same. Any Ideas what could be the issue here?
It turns out that I wasn't calling the function with the code for changing the value correctly, which means the code didn't get executed. Seems like this was an issue with some other part of my code, after making sure the setVolume()
method actually gets called, it worked.