Cannot Read Property Of Send Of Undeifined (distube npm) Event Handler

609 Views Asked by At

So, I tried making an event handler for the music events (below) and the events load. But Once I starting a song, the event loads, even though the message may be defined it is saying that send is undefined.

Distube Event Handler Below:

    const Distube = require(`distube`)

    client.distube = new Distube(client, { searchSongs: false, emitNewSongOnly: true});

    const music = fs.readdirSync(`./music`).filter(file => file.endsWith(`.js`));

    for (const file of music){
        console.log(`Loading Music Event: ${file}`);
        const event = require(`./music/${file}`);
        client.distube.on(file.split(".")[0], event.bind(null, client));
    }

Below Is The Event File Which Is Under ./music/playSong (I made playSong as a test event, to see if it would work)

    const Discord = require(`discord.js`)
module.exports = (message, queue, song) => {
    message.channel.send(`Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}}`)
}

Full Error Below:

(node:9000) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
    at module.exports (E:\SoftwareGithubRep\MoosacBot\music\playSong.js:3:17)

Any Help Would Be Appreciated

0

There are 0 best solutions below