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 toolkit•3w 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
duck•3w 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
acatto•3w 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
acatto•3w ago
No description
duck
duck•3w ago
which suggests connection is undefined
d.js docs
d.js docs•3w ago
- ReferenceError: "x" is not defined: learn more - TypeError: Cannot read properties of undefined/null (reading "x"): learn more
acatto
acatto•3w 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
duck•3w ago
it starts at 100% since your deps were previously an issue, let's start by confirming those
d.js docs
d.js docs•3w ago
:guide: Getting Started: Introduction - Debugging Dependencies read more
acatto
acatto•3w 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
duck•3w 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
acatto•3w ago
okay give me one sec lemme update them which versions are they now on?
duck
duck•3w 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
acatto•3w ago
so confusing, i installed 0.1.1 but it still says 0.0.8 oh it's discord.js's opusscript
duck
duck•3w ago
not sure what you mean by that given that neither discord.js nor any of the subpackages depend on opusscript
acatto
acatto•3w ago
correct me if i'm wrong, but this is discord.js's version of opusscript integrated in @discordjs/voice
No description
duck
duck•3w ago
not exactly furthermore I have to ask, are you editing your lockfile directly?
acatto
acatto•3w 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