[英]Discord.js joining voice channel
我需要我的機器人加入准備就緒的語音頻道這是我的代碼
const { joinVoiceChannel } = require('@discordjs/voice');
client.on('ready', () => {
joinVoiceChannel({
channelId: client.channels.cache.get('862785346767814696')
})
})
它返回錯誤(o 不是函數)
嘗試這個。
client.on("ready", () => {
const channel = client.channels.cache.get("862785346767814696");
if (!channel) return console.error("The channel does not exist!");
channel.join().then(connection => {
console.log("Successfully connected.");
}).catch(e => {
console.error(e);
});
});
您必須指定公會 ID 和語音適配器創建者
joinVoiceChannel({
channelId: "channelId",
guildId: "guildId",
adapterCreator: client.guilds.cache.get("guildId").voiceAdapterCreator
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.