[英]Discord.js joining voice channel
I need my bot joins a voice channel on ready here is my code我需要我的机器人加入准备就绪的语音频道这是我的代码
const { joinVoiceChannel } = require('@discordjs/voice');
client.on('ready', () => {
joinVoiceChannel({
channelId: client.channels.cache.get('862785346767814696')
})
})
it return with error (o is not a function)它返回错误(o 不是函数)
Try this.尝试这个。
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);
});
});
You have to specify a guild ID and voice adapter creator您必须指定公会 ID 和语音适配器创建者
joinVoiceChannel({
channelId: "channelId",
guildId: "guildId",
adapterCreator: client.guilds.cache.get("guildId").voiceAdapterCreator
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.