0

I want to make the bot detect when a user is talking. in the discord documentation I saw i needed to use the event guildMemberSpeaking. This is the code:

const Discord = require('discord.js');
const client = new Discord.Client();


client.once('ready', () => {
    console.log('Talkover is online!');
})


// Joins the voice channel with every tekst
client.on('message', async message => {
    // Join the same voice channel of the author of the message
    if (message.member.voice.channel) {
        const connection = await message.member.voice.channel.join();

    }
});


client.on('guildMemberSpeaking', (member, speaking) => {

    if (speaking) {
        console.log('speaking');
    } else {
        console.log('notspeaking');
    }

});

for some reason message works but guildmemberspeaking not. I don't know what I'm doing wrong.

Kyle Van Raay
  • 228
  • 1
  • 2
  • 11
  • See if this answers your question, https://stackoverflow.com/questions/64739350/discord-js-bot-welcomes-member-assign-a-role-and-send-them-a-dm/64739684#64739684 – Worthy Alpaca Nov 10 '20 at 20:07

1 Answers1

0

You have to use an async listener my friend

client.on('guildMemberSpeaking', async (member, speaking) => {
    if (speaking) {
        console.log('speaking');
    } else {
        console.log('notspeaking');
    }
});

Just add async before your parameters and you're done.

ouflak
  • 2,458
  • 10
  • 44
  • 49