Discord.js bot joining voice channel but wont run the remaining code after joining

ADragonDood

I have a discord bot that I'm trying to get to join a voice channel and have it repeat a sound file, so far I have got it to join but after it joins, none of the code in the arrow function is run

let channel = client.channels.cache.get('723620872572895243')

channel.join(connection => {
    console.log("Starting")
    mp3("speech.mp3", function (err, duration) {
        if (err) return console.log(err);
        console.log("File duration:" + duration * 1000 + "ms")
        repeat(connection, duration)
    })
}).catch(console.error)

This is the code I'm trying to run but it joins the channel and nothing after the arrow function is run

Here is the repeat() function in case it is needed

function repeat(connection, duration) {
const dispatcher = connection.play("speech.mp3")
let play = setInterval(function () {
    const dispatcher = connection.play("speech.mp3")
    console.log("Playing")
}, duration * 1000 + 2000)
module.exports.interval = play
}
Pentium1080Ti

VoiceChannel#join takes no parameters. You haven't formed your arrow function correctly, which is why none of your code is working, you need to have the .then() after the .join() like this:

let channel = client.channels.cache.get('723620872572895243')

channel.join().then(connection => {
    console.log("Starting")
    mp3("speech.mp3", function (err, duration) {
        if (err) return console.log(err);
        console.log("File duration:" + duration * 1000 + "ms")
        repeat(connection, duration)
    });
}).catch(console.error)

You can see more about the VoiceChannel#join method here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Joining a voice channel on ready (discord.js)

From Dev

Discord.py bot leaving voice channel

From Dev

Discord.js Voice Channel with Slash Commands

From Dev

discord.js voice channel member count

From Dev

Discord js / Check if user is in an specific voice Channel

From Dev

Discord bot can't connected to voice channel (python)

From Dev

discord.errors.ClientException: Already connected to a voice channel music bot

From Dev

discord music bot error, ClientException: Already connected to a voice channel in this server

From Dev

Discord.JS code wont work?

From Dev

Laravel echo send data when joining channel

From Dev

irssi: how to hide names when joining channel?

From Dev

Removing parenthesis after joining RDDs

From Dev

Joining String after certain steps

From Dev

Removing parenthesis after joining RDDs

From Dev

Printing "none" after joining a list

From Dev

Select after joining three tables

From Dev

code for codeigniter for joining same table with AS

From Dev

Ext Js store joining filters

From Dev

Twilio Chat: Error User not member of channel while joining a private channel

From Dev

Discord.js - Bot won't specify/mention the channel in logs

From Dev

SQL Joining rows after using count

From Dev

SQL Joining rows after using count

From Dev

Merging Null int Column after joining

From Dev

CakePHP - Paginate data after joining tables

From Dev

Count rows after joining three tables in PostgreSQL

From Dev

Not getting required result after joining 2 tables

From Dev

Miracast connection error after joining ad domain

From Dev

Processes not joining even after flushing their queues

From Dev

Error after joining objects in Apache Pig

Related Related

HotTag

Archive