我想让机器人检测用户何时说话。在不和谐的文档中我看到我需要使用该事件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 即可完成。
添加回答
举报
0/150
提交
取消