I am creating a Discord Bot and I am getting along quite good, however, I am now trying to implement a command for changing the volume of the bot and I can't figure out how to do it. All I am finding on the Internet is for V12 or below, but I am using the new version of discord.js - V13. Here is what I have for playing the music:
const connection = await connect(channel);
const audioPlayer = createAudioPlayer();
const stream = createStream(song.url);
const resource = createAudioResource(stream, {
inputType: StreamType.Arbitrary,
});
stream.on('error', () => playQueue(guild, channel));
connection.subscribe(audioPlayer);
audioPlayer.play(resource);
This all works but does one of you know how to change the volume?
Side question:
I am also trying to make a /seek <time>
to jump to any place in the video and neither am I making any progress with that.
I fixed it now, thanks to Leau:
The problem I had was that I was trying to set resource.volume
to the value, whereas I actually would have had to do it via resource.volume.setVolume()
with the @discordjs/opus package installed and the option on resource for inlineVolume
set to true