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

245
Views
TypeError: client.voice.createBroadcast is not a function

This is my code:

const secret = require('./secret.json'); //file with your bot credentials/token/etc
const discord = require('discord.js');
const discordTTS = require('discord-tts');
const client = new discord.Client();
client.login(secret.token);

client.on('ready', () => {
    console.log('Online');
});

client.on('message', msg => {
    if(msg.content === 'say test 123'){
        const broadcast = client.voice.createBroadcast();
        const channelId = msg.member.voice.channelID;
        const channel = client.channels.cache.get(channelId);
        channel.join().then(connection => {
            broadcast.play(discordTTS.getVoiceStream('test 123'));
            const dispatcher = connection.play(broadcast);
        });
    }
});

Output comes out with an error:

TypeError: client.voice.createBroadcast is not a function

I am using Node:17.0.0 and Discord.js:13.1.0

I am not sure why I am getting this error.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Discord.js v13 no longer supports voice. The new way to join a VC and play audio is with the @discordjs/voice library.

const { joinVoiceChannel, createAudioPlayer } = require("@discordjs/voice")
const player = createAudioPlayer()
joinVoiceChannel({
  channelId: msg.member.voice.channel.id,
  guildId: msg.guild.id,
  adapterCreator: msg.guild.voiceAdapterCreator
}).subscribe(player) //join VC and subscribe to the audio player
player.play(audioResource) //make sure "audioResource" is a valid audio resource

Unfortunately, discord-tts might be deprecated. You can record your own user client speaking the message and save it to an audio file. Then you can create an audio resource like this:

const { createAudioResource } = require("@discordjs/voice")
const audioResource = createAudioResource("path/to/local/file.mp3")
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!