【问题标题】:Discord BOT, guildMemberSpeaking event is not workingDiscord BOT,guildMemberSpeaking 事件不起作用
【发布时间】:2021-02-22 19:20:20
【问题描述】:

我想让机器人检测用户何时说话。在我看到的不和谐文档中,我需要使用事件guildMemberSpeaking。这是代码:

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');
    }

});

由于某种原因,消息有效,但公会成员却没有。我不知道我做错了什么。

【问题讨论】:

标签: javascript events discord opus


【解决方案1】:

我的朋友,你必须使用异步监听器

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

只需在参数前添加 async 即可。

【讨论】:

    猜你喜欢
    • 2020-08-16
    • 2021-02-28
    • 2021-10-22
    • 1970-01-01
    • 2022-10-15
    • 2018-07-08
    • 2021-01-05
    • 2020-08-07
    • 1970-01-01
    相关资源
    最近更新 更多