I'm trying to make a play command for my discord bot, but it gives me this error :
TypeError: adapterCreator is not a function
Here is my code:
const ytdl = require('ytdl-core');
module.exports ={
name:'play',
description:'aaaaaaaaaaaam',
execute(message, args){
const { joinVoiceChannel, createAudioPlayer, createAudioResource, generateDependencyReport } = require('@discordjs/voice');
const url = 'https://www.youtube.com/watch?v=NevKVKbCNy4&ab_channel=NTDM'
const stream = ytdl(url, {filter: 'audioonly'});
const player = createAudioPlayer();
const resource = createAudioResource(stream);
const GuildMember = message.author.id;
const connection = joinVoiceChannel({
channelId: GuildMember.voiceChannel,
guildId: message.guild.id,
adapterCreator: message.channel.guild.voiceAdatperCreator
})
connection.subscribe(player);
player.play(resource);
console.log(generateDependencyReport());
}
}
The problem lies in your joinVoiceChannel():
const connection = joinVoiceChannel({
channelId: message.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator
});
Your const GuildMember = message.author.id is actually a string, in which case you cannot do GuildMember.voiceChannel.
message.guildId & message.channelId are shorthands to getting the respective ids.
I suggest reading the voice documentation here: