亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Discord BOT,guildMemberSpeaking 事件不起作用

Discord BOT,guildMemberSpeaking 事件不起作用

LEATH 2023-07-20 16:27:14
我想讓機器人檢測用戶何時說話。在不和諧的文檔中我看到我需要使用該事件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 tekstclient.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');    }});由于某種原因,消息有效,但公會成員無法說話。我不知道我做錯了什么。
查看完整描述

1 回答

?
桃花長相依

TA貢獻1860條經驗 獲得超8個贊

你必須使用異步偵聽器我的朋友


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

    if (speaking) {

        console.log('speaking');

    } else {

        console.log('notspeaking');

    }

});

只需在參數之前添加 async 即可完成。


查看完整回答
反對 回復 2023-07-20
  • 1 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號