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

120
Views
Bot won't join voice channel

I have a problem where I've joined a voice channel and I want to play a song but the bot tells me to join a voice channel even though I'm already in one here's an image

Here's my code:

import ytdl from 'ytdl-core'
import ytSearch from 'yt-search'
export const name = 'play';
export const description = 'Play a desired song!';
export const args = 1;
export const usage = '{song}';
export const execute = async (message, args) => {
const voiceChannel = message.member.voice.channel;
if (!voiceChannel) return message.channel.send('Please join a voice channel first!');

const connection = await joinVoiceChannel();

const videoFinder = async (query) => {
    const videoResult = await ytSearch(query);

    return (videoResult.videos.length > 1) ? videoResult.videos[0] : null;

}

const video = await videoFinder(args.join(' '));

if (video) {
    const stream = ytdl(video.url, { filter: 'audioonly' });
    connection.play(stream, { seek: 0, volume: 1 })
        .on('finish', () => {
            voiceChannel.leave();
        });

    await message.reply(`:arrow_forward: Now playing ***${video.title}***`)
} else {
    message.channel.send(`I could not find the video :c`)
}

}

This is the first time I'm asking for help here, so if something isn't clear please ask me any questions!

Help would be heavily appreciated (I think it's because joinVoiceChannel(); is not a function.)

about 4 years ago · Juan Pablo Isaza
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!