Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord.js 13 channel.join is not a function

I recently installed Discord.js 13.1.0 and my music commands broke because, apparently, channel.join(); is not a function, although I have been using it for months on 12.5.3...

Does anybody know a fix for this?

Some parts of my join command:

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

await channel.join();

It results in the error.

like image 291
nikoszz Avatar asked Aug 14 '21 16:08

nikoszz


People also ask

Does discord js use node JS?

discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.


Video Answer


1 Answers

Discord.js no longer supports voice. You need to use the other package they made (@discordjs/voice). You can import joinVoiceChannel from there.

//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
        })
    }
})
like image 67
MrMythical Avatar answered Oct 19 '22 05:10

MrMythical