如何让我的discord机器人加入用户所在的vc?
我试图让我的机器人加入一个用户所在的vc,当我说“+sing”时。音频完成后,机器人应断开与vc的连接。就我所知,我不知道我做错了什么如何让我的discord机器人加入用户所在的vc?,discord,discord.js,bots,voice,ytdl,Discord,Discord.js,Bots,Voice,Ytdl,我试图让我的机器人加入一个用户所在的vc,当我说“+sing”时。音频完成后,机器人应断开与vc的连接。就我所知,我不知道我做错了什么 client.on("message", msg => { if (message.content === '+sing') { const connection = msg.member.voice.channel.join() channel.join().then(connection => {
client.on("message", msg => {
if (message.content === '+sing') {
const connection = msg.member.voice.channel.join()
channel.join().then(connection => {
console.log("Successfully connected.");
connection.play(ytdl('https://www.youtube.com/watch?v=jRxSRyrTANY', { quality: 'highestaudio' }));
}).catch(e => {
console.error(e);
connection.disconnect();
})
});
顺便说一句,我使用的是discord.js。您可以获取它们的名称,并将其用作要加入的通道对象
client.on(“message”,msg=>{
如果(message.content==='+sing'){
//您应该添加一个检查,以确保它们位于语音频道中
//加入他们的频道
const connection=msg.member.voice.channel.join()
}
})