How do I make an event listener for when someone speaks?

I want to make an event listener similar to how the make events in the discord.js guide const { Events } = require('discord.js'); module.exports = { name: Events.ClientReady, once: true, execute(client) { console.log(Ready! Logged in as ${client.user.tag}); }, }; Similar to this but with an event for when someone speaks voiceConn.receiver.speaking.on("start",... I can do this, but only in my index file and in a slash command
6 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Deleted User d4342210#4970
"dependencies": { "@discordjs/core": "^0.6.0", "@discordjs/opus": "github:discordjs/opus", "@discordjs/voice": "^0.16.0", "discord.js": "^14.11.0", node v18.16.0
duck
duck2y ago
not sure why you're using both /core and the main lib also unsure why you're installing opus from the repo but to answer your actual question, you can just create a similar event file for the SpeakingMap events start and end, but you'd need to create a separate event loader to listen to these events (be it everytime a VoiceConnection is created, or at some other arbitrary time) or you could just load and listen manually
Deleted User d4342210#4970
I was throwing shit at the fan because I was dealing with an annoying issue so if there is stuff to uninstall please let me know! I would love to make this as light as possible(opus from the repo, I didn't know there was another option...) Thank you 🙂 what do you mean create another event loader to listen to the speaking map event? wouldn't speaking map only work if its connected to a voice connection? in the case of "just load or listen manually" is it worth making an separate event for it. I have the voiceConn.receiver.speaking.on("start",... event in my join slash command (I wanted to move it to another file for neatness thats all)
duck
duck2y ago
so if there is stuff to uninstall please let me know!
I'm assuming you're using the mainlib, so feel free to remove /core
opus from the repo, I didn't know there was another option...
@discordjs/opus is also on the npm registry, same as any of the other submodules
what do you mean create another event loader to listen to the speaking map event? wouldn't speaking map only work if its connected to a voice connection?
yes, that's why you'd need a separate event loader, one that handles listening to the events whenever a VoiceConnection is created or at some other arbitrary time given an existing VoiceConnection object
in the case of "just load or listen manually" is it worth making an separate event for it
it's entirely up to you
Deleted User d4342210#4970
for simplicity I will leave it, but I am happy to finally find an answer Thank you so much for the help!!
Want results from more Discord servers?
Add your server