Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Cannot read properties of undefined (reading 'adapterCreator')

I am attempting to make a music bot for my discord server. When I run the code, the bot joins my call however it instantly stops the code and it executes the "An error occurred trying to connect."

It says in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'adapterCreator') No debugger available, can not send 'variables' Process exited with code 1

The only part of code where 'adapterCreator' comes from is here:

if (command === 'play'){
    if (!args.length) return message.channel.send('Please provide the second argument!');
    let song = {};
    joinVoiceChannel({
        channelId: message.member.voice.channel.id,
        guildId: message.guild.id,
        adapterCreator: message.guild.voiceAdapterCreator
    })

The code that defines message:

This is all under async execute(message, args, command, client, Discord){} in the play.js folder

const voiceChannel = message.member.voice.channel;
if (!voiceChannel) return message.channel.send('You must be in a channel to run this command!')
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has('CONNECT')) return message.channel.send('You do not have the permissions to do this!');
if(!permissions.has('SPEAK')) return message.channel.send('You do not have the permissions to do this!');
const server_queue = queue.get(message.guild.id);

In main.js Command Handler:

   else if (command === 'play'){
       client.commands.get('play').execute(message, args, command);

   }

EDIT #2: Showing intents:

const { Client, Intents, DiscordAPIError, Collection } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

const prefix = '-'

const fs = require('fs');
client.commands = new Collection();
const command = require('./command')

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);
    client.commands.set(command.name, command);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I just tried the same way you did it in your code and it worked just fine and I can't reproduce the crash. So the problem might not be the code.

Have you tried to update the packages ? (npm update)

You have a DeprecationWarning for the on message event. This won't fix the problem but it would be good to change it to messageCreate.

Also to play music later you will need the connection when the bot joins a voice channel. Assign the result from joinVoiceChannel to a variable.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!