如何让我的 discord 机器人加入用户所在的 vc?
How do I get my discord bot to join a vc that a user is in?
我正在尝试让我的机器人在说“+唱歌”时加入用户所在的 vc。音频结束后,机器人应该与 vc 断开连接。这是我得到的,我不知道我做错了什么。
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。
你可以获得他们的 GuildMember#VoiceState#channel 并将其用作加入的频道对象
client.on("message", msg => {
if (message.content === '+sing') {
// you should add a check to make sure they are in a voice channel
// join their channel
const connection = msg.member.voice.channel.join()
}
})
我正在尝试让我的机器人在说“+唱歌”时加入用户所在的 vc。音频结束后,机器人应该与 vc 断开连接。这是我得到的,我不知道我做错了什么。
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。
你可以获得他们的 GuildMember#VoiceState#channel 并将其用作加入的频道对象
client.on("message", msg => {
if (message.content === '+sing') {
// you should add a check to make sure they are in a voice channel
// join their channel
const connection = msg.member.voice.channel.join()
}
})