我已经找到了这段代码,但是我不知道如何在index.js
中使用它。有任何想法吗?
voiceChannel.join()
.then(connection => {
connection.voice.setSelfDeaf(true);
});
答案 0 :(得分:0)
作为对您的评论的答复,以下代码将在您的漫游器每次加入语音通道时对其进行辩护。
client.on("voiceStateUpdate", (oldVoiceState, newVoiceState) => {
if (!newVoiceState.channel) {return false}; // The bot disconnected.
if (newVoiceState.id == client.user.id) { // Checking if it is the bot.
newVoiceState.setSelfDeaf(true); // Setting self defean to true.
};
});
要让您的漫游器加入语音通道:
// Getting the channel.
const channel = client.channels.cache.get("722944525986955386");
// Joining the channel.
channel.join();