首页 > 解决方案 > Discord.js 13 channel.join 不是函数

问题描述

我最近安装了 Discord.js 13.1.0 并且我的音乐命令坏了,因为显然channel.join();它不是一个功能,尽管我在 12.5.3 上已经使用了几个月......

有人知道解决这个问题吗?

我的 join 命令的某些部分:

const { channel } = message.member.voice;
const voiceChannel = message.member.voice.channel;

await channel.join();

它导致错误。

标签: discorddiscord.js

解决方案


Discord.js 不再支持语音。您需要使用他们制作的其他软件包(@discordjs/voice)。joinVoiceChannel您可以从那里导入。

//discord.js and client declaration
const { joinVoiceChannel } = require('@discordjs/voice');
client.on('messageCreate', message => {
    if(message.content === '!join') {
        joinVoiceChannel({
            channelId: message.member.voice.channel.id,
            guildId: message.guild.id,
            adapterCreator: message.guild.voiceAdapterCreator
        })
    }
})

推荐阅读