Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
TypeError: Cannot read properties of undefined (reading 'source')

So i tried to make a tts functionfor my discord.js bot using this code:

const { SlashCommandBuilder } = require("@discordjs/builders")
const { getAudioUrl } = require('google-tts-api');

module.exports = {
    data: new SlashCommandBuilder().setName("talk").setDescription("Nói tin nhắn trong voice channel").addStringOption((option) =>
    option.setName("text").setDescription("Your text").setRequired(true)),

    _run: async ({ client, interaction }) => {
        if (!interaction.member.voice.channel)
            return interaction.editReply("Mày phải vào một ``voice channel`` để sử dụng lệnh này.");

        const queue = client.player.getQueue(interaction.guildId);
        if (queue)
            return await interaction.editReply("Nhạc đang được bật. Vui lòng thử lại khi nhạc được tắt.");

        const text = interaction.options.getString("text");
        if (text > 200)
            return await interaction.editReply("Tin nhắn không được quá 200 chữ.");

        const voiceChannel = await client.player.createQueue(interaction.guild);
        const audioURL = await getAudioUrl(text, {
            lang: 'vi',
            slow: false,
            host: 'https://translate.google.com',
            timeout: 10000,
        });
        try {
            voiceChannel.connect(interaction.member.voice.channel).then(connection => {
                const dispatcher = connection.play(audioURL);
                dispatcher.on('finish', () => {
                    voiceChannel.disconnect();
                    message.reply('đã xong.');
                });
            });
        }
        catch (e) {
            await interaction.editReply('T lại bị lỗi rồi, đm <@877004766956363828> cứu t ;-;');
            console.error(e);
        };
    },
    get run() {
        return this._run;
    },
    set run(value) {
        this._run = value;
    },
}

but then this error appeared:

C:\Users\Administrator\Dropbox\PC\Desktop\im innocent\discord-music-bot\node_modules\discord-player\dist\Structures\Queue.js:646
            if (["youtube", "spotify"].includes(track.raw.source)) {
                                                          ^

TypeError: Cannot read properties of undefined (reading 'source')

What should I do now? And if u guys wanna see anything else please let me know. Like I have other files but i wonder if I should show them all or not or like just the main file or smth like that? I'm a node.js beginner.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda