当有人进入任何频道时,我正在尝试制作一个用于播放音乐的机器人

时间:2020-05-21 15:20:30

标签: javascript discord.js

但是appers“ ReferenceError:未定义连接” 我尝试了一些YouTube视频,但没有找到与discord.js v12匹配的任何内容

bot.on('voiceStateUpdate', (oldPresence, newPresence) => {
let newUserChannel = newPresence.voiceChannel
let oldUserChannel = oldPresence.voiceChannel
let textChannel = oldPresence.guild.channels.cache.get('TEXTCHANNEL ID')
connection.join()
.then()
if(oldUserChannel === undefined && newUserChannel !== undefined) {

  if (newMember.id === 'MEMBER ID')         
  {   
     newUserChannel.join()
     .then(connection => {
        console.log("Joined voice channel!");
        const dispatcher = connection.playFile("E:\UniConverter\Downloaded\Trio.mp3");

        dispatcher.on("end", end => {newUserChannel.leave()});
     })
      .catch(console.error);

  }
         else                                      
           textChannel.send("Hello") 
         } 
  } 
);

bot.login (token);

0 个答案:

没有答案