Reputation: 35
I am having a problem with ytdl-core. My bot can’t play anything. In my console it says Playing: (song)
but it doesn’t play anything at all. Everything is worked perfectly except it can't play any song. Here is the code.
const config = require('../config/settings.json');
const queueFilename = './data/queue.txt';
const queue = fs.readFileSync(queueFilename).toString().split('\n');
const queueLength = queue.length;
async function playMusic(conn, entry = 0) {
const song = queue[entry];
try {
const stream = ytdl(song, {
quality: 'highestaudio',
highWaterMark: 1<<25
});
stream.on('info', info => {
curSong = info.title;
logger.info(`Playing: ${curSong}`);
updatePresence(`► ${curSong}`);
if (listeners <= 1) {
dispatcher.pause();
updatePresence(`❙ ❙ ${curSong}`);
logger.info(`Nobody is listening in ${channel.name}, music has been paused.`);
}
});
dispatcher = await conn.play(stream);
dispatcher.on('end', () => {
if (entry == queueLength - 1) playMusic(conn);
else playMusic(conn, entry + 1);
});
dispatcher.on('error', err => {
logger.error(err);
if (entry == queueLength - 1) playMusic(conn);
else playMusic(conn, entry + 1);
});
} catch (err) {
logger.error(err);
if (entry == queueLength - 1) playMusic(conn);
else playMusic(conn, entry + 1);
}
}
Upvotes: 0
Views: 392
Reputation: 11
I had the same error, I don't know what caused it, but what I did was uninstall it and reinstall it, and now it works fine.
Use these commands:
npm uninstall ytdl-core
npm uninstall ytdl-core-discord
npm install ytdl-core
npm install ytdl-core-discord
Upvotes: 1