Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the volume of my discord bot in discord.js V13?

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.

like image 855
tzimom Avatar asked Sep 18 '25 13:09

tzimom


1 Answers

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

like image 176
tzimom Avatar answered Sep 21 '25 14:09

tzimom