- What are your intents?
GuildVoiceStatesis 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!
#First time using DJS/VC
57 messages · Page 1 of 1 (latest)
it returns ```
An error occurred: Cannot read properties of undefined (reading 'ended')
its my first time using the voice part of DJS
can you show the full error
yeah hang on a minute
An error occurred: TypeError: Cannot read properties of undefined (reading 'ended')
at AudioPlayer.play (C:\Users\yusuf\Documents\programming projects\discordbots\emirates safety\node_modules\@discordjs\voice\dist\index.js:1126:18)
at Object.run (C:\Users\yusuf\Documents\programming projects\discordbots\emirates safety\src\commands\play-safety.js:35:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\yusuf\Documents\programming projects\discordbots\emirates safety\node_modules\commandkit\dist\index.js:643:7)
you don't pass the audioresource to <AudioPlayer>.play(...) there
I placed the audioPlayer.play() line to after the declaration of subscription and it still returned the same error 😦
guide suggestion for @opal crest:
Library: Audio Player - Playing audio
read more
Right. I have corrected my code to
const { SlashCommandBuilder } = require("discord.js");
const {
joinVoiceChannel,
getVoiceConnection,
createAudioPlayer,
createAudioResource
} = require("@discordjs/voice");
const path = require("path");
module.exports = {
data: new SlashCommandBuilder()
.setName("play-safety")
.setDescription("Plays the safety demo!")
.addChannelOption(option => option.setName("vc").setDescription("the vc that you want the bot to join!")),
/**
* @param {Object} options
* @param {import("discord.js").Interaction} options.interaction
*/
run: async ({ interaction }) => {
try {
await interaction.deferReply()
const channel = interaction.options.getChannel("vc")
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
})
const audioPlayer = createAudioPlayer()
const resource = createAudioResource(path.join(__dirname, 'audio.mp3'));
const subscription = connection.subscribe(audioPlayer)
audioPlayer.play(resource)
} catch (error) {
console.error("An error occurred:", error);
interaction.followUp(
"An error occurred while trying to play the audio. Please check the logs."
);
}
},
};
now it is not returning an error but it is also not playing the audio
time for the dependency report then
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.18.0
- prism-media: 1.3.5
Opus Libraries
- @discordjs/opus: not found
- opusscript: not found
Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: not found
- @stablelib/xchacha20poly1305: not found
- @noble/ciphers: not found
FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
well, there you go. missing both an opus and an encryption library
ohhh
npm i @discordjs/opus
returns a massive error
hang on
read the big information telling you what to do in the middle there. between the ******************
right the ```
This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
?
that's the first line. neither in the middle nor between ****************************
oh
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
heheh
but with latest node versions you should be able to just tick the box to install those with the node installer on windows
so I can just rerun the nodejs installer instead of the whole VS thingy?
yes (and tick the box to include those build tools)
Chocolately?
that was the onyl checkbox in the installer
it still dont work
🫤
does npm install --global windows-build-tools work?
nope
returns that
who knew a discord bot for an airplane safety demo would be this difficult
😭
im bt to have a mental breakdown over ts
you did run this one: https://nodejs.org/en/download/prebuilt-installer ? and it didn't have an option to install build tools/C++ in it?
nope just
i ticked that box
yes, that's the correct box... it literally says "build tools" and "C++" there...
i swr i did that
hang on so now npm installing opus should work?
yes
did you (re)start a new terminal after doing that? does it actually use the node/npm version you just installed?
yep
opened a new cmd
@pliant bloom u got any other ideas?