当用户切换频道时,我想把机器人从一个频道移到另一个频道。
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()
}
});
}
解决方案:
你只需要使用 newState
‘s voiceChannel
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();
}
});
本文来自投稿,不代表实战宝典立场,如若转载,请注明出处:https://www.shizhanbaodian.com/25990.html