user14302998
user14302998

Reputation: 31

(Discord.js) How to detect when user is starting/stopping to speak in specific voice channel

I know there are following option in the documentation like .speaking

I'm trying to find a handler, like client.on('start/stop speaking', ...) but I didn't find anything about something like this. Can someone help me with this please? I don't like to set an interval with a 0 delay and check all members in channel every time. I know how to get user and channel, but I can't figure out how make a handler for speaking

Upvotes: 3

Views: 3168

Answers (2)

Lioness100
Lioness100

Reputation: 8412

You can use guildMemberSpeaking

enter image description here

Upvotes: 1

node_modules
node_modules

Reputation: 4925

There is an event called voiceStateUpdate according to the documentation. There is also a read only key called .speaking. The oldState and newState are members of the VoiceState class.

And this is how it works:

client.on("voiceStateUpdate", (oldState, newState) => {
     // Do anything here with the updated state.
     if(oldState.speaking !== newState.speaking) {

        // User started speaking
     }
});

Upvotes: 0

Related Questions