Cannot play audio as no valid encryption package is installed

I literally have sodium, libsodium and libsodium-wrappers installed and yet it still throws this damn error.
Error: Cannot play audio as no valid encryption package is installed.
- Install sodium, libsodium-wrappers, or tweetnacl.
- Use the generateDependencyReport() function for more information.

at Object.fallbackError (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:166:9)
at Networking.encryptOpusPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:663:17)
at Networking.createAudioPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:653:50)
at Networking.prepareAudioPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:599:33)
at VoiceConnection.prepareAudioPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:1412:29)
at AudioPlayer._preparePacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:981:18)
at AudioPlayer._stepPrepare (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:962:14)
at prepareNextAudioFrame (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:87:29)
at audioCycleStep (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:76:3)
at Timeout._onTimeout (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:83:45)
Error: Cannot play audio as no valid encryption package is installed.
- Install sodium, libsodium-wrappers, or tweetnacl.
- Use the generateDependencyReport() function for more information.

at Object.fallbackError (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:166:9)
at Networking.encryptOpusPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:663:17)
at Networking.createAudioPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:653:50)
at Networking.prepareAudioPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:599:33)
at VoiceConnection.prepareAudioPacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:1412:29)
at AudioPlayer._preparePacket (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:981:18)
at AudioPlayer._stepPrepare (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:962:14)
at prepareNextAudioFrame (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:87:29)
at audioCycleStep (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:76:3)
at Timeout._onTimeout (file:///C:/Users/bin/Desktop/Mastery/node_modules/@discordjs/voice/dist/index.mjs:83:45)
28 Replies
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
xubby
xubbyโ€ข2y ago
FeelsBadMan
Idris
Idrisโ€ข2y ago
what you didnโ€™t get in the error? itโ€™s literally written to install libsodium-wrappers
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
Idris
Idrisโ€ข2y ago
ah yeah it points to .mjs file not .js mb npm i @discordjs/voice@0.11.0
xubby
xubbyโ€ข2y ago
am using v14 aight let me try it out rn it doesn't throw that error but now the audio isn't even played and no errors at all ๐Ÿ˜ถ I guess the package is broken?
Idris
Idrisโ€ข2y ago
show the code
xubby
xubbyโ€ข2y ago
import { Client, Events, GatewayIntentBits } from 'discord.js'
import { joinVoiceChannel, createAudioPlayer, createAudioResource, NoSubscriberBehavior } from '@discordjs/voice';
import defaults from './config.json' assert {type: 'json'};

const { btoken } = defaults;
const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates]});

client
.once(Events.ClientReady, (client) => {
console.log(`Logged in as ${client.user.tag}`);

const connection = joinVoiceChannel({
channelId: '1025776338772181053',
guildId: '1018496841949650994',
adapterCreator: client.guilds.cache.get('1018496841949650994')!.voiceAdapterCreator,
selfMute: false,
selfDeaf: false
});

try {
const player = createAudioPlayer();
const resource = createAudioResource('./Tasbih.mp3');

player.play(resource);
connection.subscribe(player);

} catch(err) {console.error(err)}
})
.login(btoken);
import { Client, Events, GatewayIntentBits } from 'discord.js'
import { joinVoiceChannel, createAudioPlayer, createAudioResource, NoSubscriberBehavior } from '@discordjs/voice';
import defaults from './config.json' assert {type: 'json'};

const { btoken } = defaults;
const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates]});

client
.once(Events.ClientReady, (client) => {
console.log(`Logged in as ${client.user.tag}`);

const connection = joinVoiceChannel({
channelId: '1025776338772181053',
guildId: '1018496841949650994',
adapterCreator: client.guilds.cache.get('1018496841949650994')!.voiceAdapterCreator,
selfMute: false,
selfDeaf: false
});

try {
const player = createAudioPlayer();
const resource = createAudioResource('./Tasbih.mp3');

player.play(resource);
connection.subscribe(player);

} catch(err) {console.error(err)}
})
.login(btoken);
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
xubby
xubbyโ€ข2y ago
Way ahead of that and error still persists ๐Ÿฅฒ
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
xubby
xubbyโ€ข2y ago
๐Ÿ˜‚ Thanks for the help too ๐Ÿ™๐Ÿฝ
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
xubby
xubbyโ€ข2y ago
Idk when this issue will be solved FeelsBadMan
Idris
Idrisโ€ข2y ago
in the next release
Aman
Amanโ€ข2y ago
You have to create a readable stream using fs first:
const fs = require('node:fs');
const resource = createAudioResource(fs.createReadStream('./Tasbih.mp3'));
const fs = require('node:fs');
const resource = createAudioResource(fs.createReadStream('./Tasbih.mp3'));
xubby
xubbyโ€ข2y ago
Since when and if so, why wasn't it mentioned or directed anywhere?! ๐Ÿคจ
xubby
xubbyโ€ข2y ago
This is all I see
Idris
Idrisโ€ข2y ago
ah well there was a new release that fixes your original issue
xubby
xubbyโ€ข2y ago
Ohh alright I'll check it out. Thanks for the heads up!
Aman
Amanโ€ข2y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Aman
Amanโ€ข2y ago
There's no proper guide anywhere you just have to try out all ways tbh..
Idris
Idrisโ€ข2y ago
didn't use /voice for a while but I know someone that used that: https://discordjs.github.io/voice/modules.html
Aman
Amanโ€ข2y ago
No i mean discordjs keeps updating every 3-6months so guides generally don't update asap, and it becomes kind of necessary to keep contacting people who know or have faced and fixed it instead :)
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
Aman
Amanโ€ข2y ago
?
xubby
xubbyโ€ข2y ago
Alr ๐Ÿ‘