Trying to play a clicking sound effect in a voice channel, however I get this instead.

Hi, My @discordjs/voice version is 0.7.5 and I'm having a slight issue with playing it. I've tried to install ffmpeg by using sudo apt install ffmpeg, however, no luck. Here's my playClickSound function:
function playClickSound(connection) {
const player = createAudioPlayer();
const resource = createAudioResource(path.resolve(__dirname, 'sound-effects/click.mp3'));
connection.subscribe(player);
player.play(resource);
player.on('error', error => {
console.error(`Error playing sound: ${error.message}`);
});

player.on('idle', () => {
console.log('Finished playing the click sound.');
});
}
function playClickSound(connection) {
const player = createAudioPlayer();
const resource = createAudioResource(path.resolve(__dirname, 'sound-effects/click.mp3'));
connection.subscribe(player);
player.play(resource);
player.on('error', error => {
console.error(`Error playing sound: ${error.message}`);
});

player.on('idle', () => {
console.log('Finished playing the click sound.');
});
}
The error is in the picture.
No description
18 Replies
d.js toolkit
d.js toolkit2mo ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - 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
duck
duck2mo ago
0.7.5 is incredibly outdated as mentioned in the pinned post here, please make sure you're using at least 0.16.0 or newer latest is 0.17.0
acatto
acattoOP2mo ago
oh wait what running npm i @discordjs/voice gives me 0.7.5 hmmm one second ok i installed 0.17.0 now oh okay, it fixed the ffmpeg error however i'm getting this now
acatto
acattoOP2mo ago
No description
duck
duck2mo ago
which suggests connection is undefined
d.js docs
d.js docs2mo ago
- ReferenceError: "x" is not defined: learn more - TypeError: Cannot read properties of undefined/null (reading "x"): learn more
acatto
acattoOP2mo ago
oh yeah mb one second well i fixed most of it however i can't get it to play the sound do i have to set the volume or is it automatically on 100%
duck
duck2mo ago
it starts at 100% since your deps were previously an issue, let's start by confirming those
d.js docs
d.js docs2mo ago
:guide: Getting Started: Introduction - Debugging Dependencies read more
acatto
acattoOP2mo ago
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5

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

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

FFmpeg
- version: 5.1.6-0+deb12u1
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5

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

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

FFmpeg
- version: 5.1.6-0+deb12u1
- libopus: yes
--------------------------------------------------
those are mine prism media is wrong tho its on the 2.0.0 alpha branch oh here's my new playClickSound() function btw:
function playClickSound(connection) {
const player = createAudioPlayer();
const resource = createAudioResource(path.resolve(__dirname, 'sound-effects/click.mp3'), {
inlineVolume: true
});
resource.volume.setVolume(1.0);
if (!connection) {
console.error('Voice connection is undefined.');
return;
}
connection.subscribe(player);
player.play(resource);

player.on('error', (error) => {
console.error(`Error playing sound: ${error.message}`);
});

player.on('idle', () => {
console.log('Finished playing the click sound.');
});
}
function playClickSound(connection) {
const player = createAudioPlayer();
const resource = createAudioResource(path.resolve(__dirname, 'sound-effects/click.mp3'), {
inlineVolume: true
});
resource.volume.setVolume(1.0);
if (!connection) {
console.error('Voice connection is undefined.');
return;
}
connection.subscribe(player);
player.play(resource);

player.on('error', (error) => {
console.error(`Error playing sound: ${error.message}`);
});

player.on('idle', () => {
console.log('Finished playing the click sound.');
});
}
duck
duck2mo ago
@discordjs/voice depends on [email protected], so I'd suggest just sticking to the version it uses opusscript and tweetnacl also look like they could use updates
acatto
acattoOP2mo ago
okay give me one sec lemme update them which versions are they now on?
duck
duck2mo ago
you can easily check yourself, and also you could just install using the latest tag but latest are [email protected] and [email protected]
acatto
acattoOP2mo ago
so confusing, i installed 0.1.1 but it still says 0.0.8 oh it's discord.js's opusscript
duck
duck2mo ago
not sure what you mean by that given that neither discord.js nor any of the subpackages depend on opusscript
acatto
acattoOP2mo ago
correct me if i'm wrong, but this is discord.js's version of opusscript integrated in @discordjs/voice
No description
duck
duck2mo ago
not exactly furthermore I have to ask, are you editing your lockfile directly?
acatto
acattoOP2mo ago
no, i'm editing my package.json i've also regenerated it i got it working thanks for the help
Want results from more Discord servers?
Add your server