Controlling volume

suppose this is my code:
const resource = createAudioResource('songs/skibidi.mp3');
const resource = createAudioResource('songs/skibidi.mp3');
how do i make this audio inline and how to control its volume? Also, what does inline audio do?
4 Replies
d.js toolkit
d.js toolkit14mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Adelto
AdeltoOP14mo ago
discord.js voice latest, same with discord.js node v 18.12.1
d.js docs
d.js docs14mo ago
interface CreateAudioResourceOptions 0.16.0 Options that are set when creating a new audio function createAudioResource 0.16.0 Creates an audio resource that can be played by audio players.
Adelto
AdeltoOP14mo ago
so
{
inputType: StreamType.Arbitrary,
}
{
inputType: StreamType.Arbitrary,
}
ryt? so
resource.volume.setVolume(10)
resource.volume.setVolume(10)
? how do i make it inlinevolume??? like createAudioResource('songs/skibidi.mp3', {inlineVolume: true});? I got this error:
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'setVolume')
at Client.<anonymous> (/home/runner/the-slave/index.js:263:23)
at Client.emit (node:events:525:35)
at Client.emit (node:domain:489:12)
at MessageCreateAction.handle (/home/runner/the-slave/node_modules/discord.js/src/client/actions/MessageCreate.js:28:14)
at module.exports [as MESSAGE_CREATE] (/home/runner/the-slave/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/the-slave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (/home/runner/the-slave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:238:12)
at WebSocketManager.emit (/home/runner/the-slave/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/home/runner/the-slave/node_modules/@discordjs/ws/dist/index.js:1103:51)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)

Node.js v18.12.1
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'setVolume')
at Client.<anonymous> (/home/runner/the-slave/index.js:263:23)
at Client.emit (node:events:525:35)
at Client.emit (node:domain:489:12)
at MessageCreateAction.handle (/home/runner/the-slave/node_modules/discord.js/src/client/actions/MessageCreate.js:28:14)
at module.exports [as MESSAGE_CREATE] (/home/runner/the-slave/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/the-slave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (/home/runner/the-slave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:238:12)
at WebSocketManager.emit (/home/runner/the-slave/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/home/runner/the-slave/node_modules/@discordjs/ws/dist/index.js:1103:51)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)

Node.js v18.12.1
my code:
if (message.content.startsWith('.vsaucemeup ?c ')) {
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const channel = message.content.split(' ?c ')[1]
const connection = joinVoiceChannel({
channelId: channel,
guildId: message.channel.guild.id,
adapterCreator: message.channel.guild.voiceAdapterCreator,
});
if (channel === "leave") {
connection.destroy()
const embed = new Discord.EmbedBuilder()
.setTitle('Now not playing The Vsauce music')
} else {
const embed = new Discord.EmbedBuilder()
.setTitle('Now playing The Vsauce music')
message.channel.send({ embeds: [embed] })
const player = createAudioPlayer();
const resource = createAudioResource('songs/vsauce.mp3');
player.play(resource);
connection.subscribe(player);
resource.volume.setVolume(10);
message.channel.send({ embeds: [embed] })
player.on(AudioPlayerStatus.Idle, () => {
player.play(createAudioResource('songs/vsauce.mp3'));
});
}
}
if (message.content.startsWith('.vsaucemeup ?c ')) {
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const channel = message.content.split(' ?c ')[1]
const connection = joinVoiceChannel({
channelId: channel,
guildId: message.channel.guild.id,
adapterCreator: message.channel.guild.voiceAdapterCreator,
});
if (channel === "leave") {
connection.destroy()
const embed = new Discord.EmbedBuilder()
.setTitle('Now not playing The Vsauce music')
} else {
const embed = new Discord.EmbedBuilder()
.setTitle('Now playing The Vsauce music')
message.channel.send({ embeds: [embed] })
const player = createAudioPlayer();
const resource = createAudioResource('songs/vsauce.mp3');
player.play(resource);
connection.subscribe(player);
resource.volume.setVolume(10);
message.channel.send({ embeds: [embed] })
player.on(AudioPlayerStatus.Idle, () => {
player.play(createAudioResource('songs/vsauce.mp3'));
});
}
}
oh wait shit i forgor
Want results from more Discord servers?
Add your server