No Audio Is Played

Hello! I'm new to using @discordjs/voice so I'm hoping I'm just missing something simple. I'm trying to get my bot to play a local audio file within voice. The bot joins the channel, but doesn't make a noise. This is the relevant code:
const player = createAudioPlayer({
debug: true,
});

const resource = createAudioResource(`/Volumes/Files/audio/music.ogg`);
const connection = joinVoiceChannel({
adapterCreator: channel.guild.voiceAdapterCreator,
guildId: channel.guild.id,
channelId: channel.id,
});

connection.subscribe(player);
connection.on("stateChange", (oldState, newState) => {
if (
oldState.status === VoiceConnectionStatus.Ready &&
newState.status === VoiceConnectionStatus.Connecting
) {
connection.configureNetworking();
}
});

player.play(resource);
player.unpause();
const player = createAudioPlayer({
debug: true,
});

const resource = createAudioResource(`/Volumes/Files/audio/music.ogg`);
const connection = joinVoiceChannel({
adapterCreator: channel.guild.voiceAdapterCreator,
guildId: channel.guild.id,
channelId: channel.id,
});

connection.subscribe(player);
connection.on("stateChange", (oldState, newState) => {
if (
oldState.status === VoiceConnectionStatus.Ready &&
newState.status === VoiceConnectionStatus.Connecting
) {
connection.configureNetworking();
}
});

player.play(resource);
player.unpause();
I was wondering if anyone could point me in the direction of the cause? The bot is auto-pausing so I believe it is do with the resource. Thank you! discord.js@14.7.1 @discordjs/voice@0.14.0 node v18.13.0
30 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Fyphen
Fyphen2y ago
Maybe you don't have to unpause the player because you have already set up required code block of u auto-paused player
Lambo
Lambo2y ago
Sorry I'm not quite sure I follow what you mean?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Fyphen
Fyphen2y ago
I meant you don't have to write player.unpause() and if you want to do that, you have to listen event that PlayerStatus.AutoPaused event and
connection.on("stateChange", (oldState, newState) => {
if (
oldState.status === VoiceConnectionStatus.Ready &&
newState.status === VoiceConnectionStatus.Connecting
) {
connection.configureNetworking();
}
});
connection.on("stateChange", (oldState, newState) => {
if (
oldState.status === VoiceConnectionStatus.Ready &&
newState.status === VoiceConnectionStatus.Connecting
) {
connection.configureNetworking();
}
});
this solve problem that recently changed so you don't have to unpause the player
Lambo
Lambo2y ago
right I see, let me have a try
Fyphen
Fyphen2y ago
maybe this wont't work please check the audio path is correctly
Lambo
Lambo2y ago
Yeah the audio path I've checked, I also tried it with a URL to an mp3 file on the web
Fyphen
Fyphen2y ago
Ahh I see Could you disable debug mode of the player?
Lambo
Lambo2y ago
Disable, sure. I just tried removing the unpause() but no luck
Fyphen
Fyphen2y ago
I think so
Lambo
Lambo2y ago
So try again with debug turned off and no unpause()
Fyphen
Fyphen2y ago
yeah
Lambo
Lambo2y ago
No difference unfortunately....
Fyphen
Fyphen2y ago
Did you install dependencys? Such as disrdjs/voice or opusscript or sodium or tweetnacl etc
Want results from more Discord servers?
Add your server