但是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);