discordjs v13 voice join channel

I hve a big issue. I have coded a music bot in nodejs. I have an array with bot data (example: bot name, id, channel id, ect.) and I create a Discord.Client for every bot in a for.

In on('ready') I create the callbacks (sending an embeded message with reaction buttons in the text channel. And when a user click on play, pause or whatever, i run a code. All fine.

When user click on the play button, the bot should connect to the voice channel from user, and play an audio. Works fine.

But now my problem:

With one bot, all works without any issues. But when I have 2 bots, and the player click on play, the correct bot comes to the channel. But when user change the channel, and play the another bot, then the old one come. I logged with console.log() and the bot ids (ex. bot.client.user.id) give the correct result. But why the old bot connect?

I am using the discordjs/voice library. And I don’t know, how I can pass the method, which client should be connect… from where the method takes the client?

That’s my join method

function playMusic(bot, botClient, channel, guildID, adapterCreator) {
    try {
        console.log("BOT ID: " + bot.id);
        console.log("BOT USER ID: " + botClient.user.id);

        let vc = joinVoiceChannel({
            channelId: channel.id,
            guildId: guildID,
            adapterCreator: adapterCreator

        let resource = createAudioResource(createReadStream('resources/audio.mp3'), {
            inlineVolume : true


        var player = createAudioPlayer();


        return player;
    } catch(ex) {

        return undefined;

Source: JavaSript – Stack Overflow

November 21, 2021
Category : News
Tags: discord.js | javascript | typescript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.