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! [email protected] @discordjs/[email protected] 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
LamboOP2y 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
LamboOP2y 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
LamboOP2y 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
LamboOP2y ago
Disable, sure. I just tried removing the unpause() but no luck
Fyphen
Fyphen2y ago
I think so
Lambo
LamboOP2y ago
So try again with debug turned off and no unpause()
Fyphen
Fyphen2y ago
yeah
Lambo
LamboOP2y ago
No difference unfortunately....
Fyphen
Fyphen2y ago
Did you install dependencys? Such as disrdjs/voice or opusscript or sodium or tweetnacl etc
Lambo
LamboOP2y ago
Core Dependencies
- @Disco#9476rdjs/voice: 0.14.0
- prism-media: 1.3.5

Opus Libraries
- @Disco#9476rdjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.11
- tweetnacl: not found

FFmpeg
- version: 5.0.1-tessus https://evermeet.cx/ffmpeg/
- libopus: yes
Core Dependencies
- @Disco#9476rdjs/voice: 0.14.0
- prism-media: 1.3.5

Opus Libraries
- @Disco#9476rdjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.11
- tweetnacl: not found

FFmpeg
- version: 5.0.1-tessus https://evermeet.cx/ffmpeg/
- libopus: yes
Do I need opusscript also? The way I read the documentation was that it was optional if using ffmpeg
Fyphen
Fyphen2y ago
No That's enough
Lambo
LamboOP2y ago
Right
Fyphen
Fyphen2y ago
Humm what is the problem?
Lambo
LamboOP2y ago
I have no idea! It just stays on autopause Rather frustrating haha
Fyphen
Fyphen2y ago
lol Try await createAudioResource
Lambo
LamboOP2y ago
It's not async is it?
Fyphen
Fyphen2y ago
I meant
Lambo
LamboOP2y ago
No difference
Fyphen
Fyphen2y ago
humm
Lambo
LamboOP2y ago
This is the state changing
Fyphen
Fyphen2y ago
ahhh auto pause caused by NoSubscriberBehavior.Paused and discord api's recently change but counteringof api's problem is already set up what's going ong here?
Lambo
LamboOP2y ago
honestly, not a clue I feel like I've been going round in circles for 48 hours mate haha
steven
steven2y ago
the counter of the API's problem doesnt work for me either. The only thing i have found that fixes it is switching regions which automatically plays the sound the moment u switch it. BUT that is so impractical in a release build for a bot so i never implemented it and now im stuck here with a major feature in my bot not working.
Lambo
LamboOP2y ago
Yeah that does not sound ideal

Did you find this page helpful?