语音状态更新事件



当用户切换通道时,我正试图将机器人从一个通道移动到另一个通道

const client = require("../index.js");
module.exports = client => {
client.on("voiceStateUpdate", (oldState, newState) => {
let oldChannel = oldState.voiceChannel, // the previous channel, if there was one
newChannel = newState.voiceChannel; // the current channel, if there is one
if (oldChannel != newChannel) {
// if the channel has changed
// do your stuff....
channel = msg.member.voice.channel
channel.join()
}
});
}

您只需要使用newStatevoiceChannel

client.on("voiceStateUpdate", (oldState, newState) => {
let oldChannel = oldState.voiceChannel, // the previous channel, if there was one
let newChannel = newState.voiceChannel; // the current channel, if there is one
if (oldChannel != newChannel) {
newChannel.join();
}
});

最新更新