Bot joins audio channel, turns green, still no sound

There is no error thrown, I don't see anything wrong. Mostly copied the guide.
client.channels.fetch(TESTCHANNEL).then(vc => {
const voiceChannelConnection = joinVoiceChannel({
channelId: TESTCHANNEL,
guildId: vc.guild.id,
adapterCreator: vc.guild.voiceAdapterCreator,
});

const musicPlayer = createAudioPlayer();
musicPlayer.on('error', error => {
console.error(`Error with audio player: ${error.message} with resource ${error.resource.metadata.title}`);
});


var currentlyPlaying = createAudioResource(path.join(__dirname,'music/defenders-of-oasis-village.mp3'));
//var currentlyPlaying = createAudioResource('music/defenders-of-oasis-village.mp3');
//currentlyPlaying.volume.setVolume(1);
musicPlayer.play(currentlyPlaying);
voiceChannelConnection.subscribe(musicPlayer);
console.log('playing?')

currentlyPlaying.playStream.on('error', error => {
console.error('Error:', error.message, 'with track', resource.metadata.title);
});
})
client.channels.fetch(TESTCHANNEL).then(vc => {
const voiceChannelConnection = joinVoiceChannel({
channelId: TESTCHANNEL,
guildId: vc.guild.id,
adapterCreator: vc.guild.voiceAdapterCreator,
});

const musicPlayer = createAudioPlayer();
musicPlayer.on('error', error => {
console.error(`Error with audio player: ${error.message} with resource ${error.resource.metadata.title}`);
});


var currentlyPlaying = createAudioResource(path.join(__dirname,'music/defenders-of-oasis-village.mp3'));
//var currentlyPlaying = createAudioResource('music/defenders-of-oasis-village.mp3');
//currentlyPlaying.volume.setVolume(1);
musicPlayer.play(currentlyPlaying);
voiceChannelConnection.subscribe(musicPlayer);
console.log('playing?')

currentlyPlaying.playStream.on('error', error => {
console.error('Error:', error.message, 'with track', resource.metadata.title);
});
})
12 Replies
skeddles
skeddles2y ago
"dependencies": {
"@discordjs/rest": "^0.1.0-canary.0",
"@discordjs/voice": "^0.11.0",
"data-store": "^4.0.3",
"discord-api-types": "^0.22.0",
"discord.js": "^13.9.0",
"ffmpeg-static": "^5.0.2",
"glob": "^7.1.6",
"libsodium-wrappers": "^0.7.10",
"node-fetch": "^2.6.1"
},
"dependencies": {
"@discordjs/rest": "^0.1.0-canary.0",
"@discordjs/voice": "^0.11.0",
"data-store": "^4.0.3",
"discord-api-types": "^0.22.0",
"discord.js": "^13.9.0",
"ffmpeg-static": "^5.0.2",
"glob": "^7.1.6",
"libsodium-wrappers": "^0.7.10",
"node-fetch": "^2.6.1"
},
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: not found
- opusscript: not found

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

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: not found
- opusscript: not found

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

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
duck
duck2y ago
looks like you're missing one of the opus libraries
After this, you'll be able to play Ogg and WebM Opus files without any other dependencies. If you want to play audio from other sources, or want to improve performance, consider installing some of the extra dependencies listed below.
skeddles
skeddles2y ago
installed @discordjs/opus, do i have to enable it in the code?
duck
duck2y ago
nope
skeddles
skeddles2y ago
still seems to be doing the same thing
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.8.0
- opusscript: not found

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

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.8.0
- opusscript: not found

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

FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
duck
duck2y ago
alright then could you listen to the stateChange event on the player and log any state changes?
skeddles
skeddles2y ago
musicPlayer.on('stateChange', (oldState, newState) => {
console.log("oldState: ", oldState.status, " | ", "NewState: ", newState.status)
});
musicPlayer.on('stateChange', (oldState, newState) => {
console.log("oldState: ", oldState.status, " | ", "NewState: ", newState.status)
});
logs:
oldState: buffering | NewState: playing
oldState: buffering | NewState: playing
duck
duck2y ago
anything else after that?
skeddles
skeddles2y ago
sometimes does more:
oldState: buffering | NewState: playing
oldState: playing | NewState: autopaused
oldState: autopaused | NewState: playing
oldState: buffering | NewState: playing
oldState: playing | NewState: autopaused
oldState: autopaused | NewState: playing
it just stays like that, sometimes it changes to idle after a while
duck
duck2y ago
autopaused comes from not having a connection subscribed, which imo means it's safer to subscribe before playing audio but in this case this shouldn't be the issue it genuinely believes it's playing audio, so it's likely the issue comes from resource itself
skeddles
skeddles2y ago
i tried putting in an invalid song path, and it switches to idle, which leads me to believe i had the path right
oldState: buffering | NewState: playing
oldState: playing | NewState: autopaused
oldState: autopaused | NewState: playing
oldState: playing | NewState: idle
oldState: buffering | NewState: playing
oldState: playing | NewState: autopaused
oldState: autopaused | NewState: playing
oldState: playing | NewState: idle
oh crap facepalm time discord switched my audio output to my microphone (??), so it was working the whole time i just couldn't hear. sorry for the wasted effort, but thank you very much for your help
duck
duck2y ago
no worries 👍