获取此错误代码:“(节点:25096)UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“ channel”

时间:2020-02-28 21:23:04

标签: discord.js

嗨,我一直试图让一个不和谐的机器人加入语音通道已有一段时间,并且一直在挣扎,这是我到目前为止的代码,当我在一般情况下键入“ / join”时会收到此消息服务器聊天。预先感谢!

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

client.login('my token);

 client.on('message', async message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;

if (message.content === '/join') {
  // Only try to join the sender's voice channel if they are in one themselves
  if (message.member.voice.channel) {
    const connection = await message.member.voice.channel.join();
  } else {
    message.reply('You need to join a voice channel first!');
  }
}
});

0 个答案:

没有答案