You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Discord music bot and one of my friends tried to play this video (warning, it is loud): https://youtu.be/ihmDR7W1P1o and it threw an error (sometimes there is no error at all but it still doesn’t play), this does not happen in 3.4.2 however it does happen with version 4 and above.
The audio part of my code:
client.on("message", message => {
var ismusicCommand = message.content.toLowerCase().startsWith(config.prefix + "play") || message.content.toLowerCase().startsWith(config.prefix + "skip") || message.content.toLowerCase().startsWith(config.prefix + "stop");
if (message.author.bot) return;
if (!message.channel.guild) {
if (ismusicCommand == true) {
message.react("723607808255197244");
message.channel.send("Music functionality can only be used while in a guild!");
return;
}
return;
}
const serverQueue = queue.get(message.guild.id);
if (message.content.toLowerCase().startsWith(config.prefix + `play`)) {
message.react("723607808062390363");
execute(message, serverQueue);
return;
} else if (message.content.toLowerCase().startsWith(config.prefix + `skip`)) {
message.react("723607808062390363");
skip(message, serverQueue);
return;
} else if (message.content.toLowerCase().startsWith(config.prefix + `stop`)) {
message.react("723607808062390363");
stop(message, serverQueue);
return;
}
});
async function execute(message, serverQueue) {
const args = message.content.split(" ");
const voiceChannel = message.member.voice.channel;
if (!voiceChannel)
return message.channel.send("You need to be in a voice channel to play audio!");
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has("CONNECT") || !permissions.has("SPEAK")) {
return message.channel.send("I need the permissions to join and play audio in your voice channel!");
}
const songInfo = await ytdl.getInfo(args[1]);
const song = {
title: songInfo.videoDetails.title,
author: songInfo.videoDetails.author.name,
url: songInfo.videoDetails.video_url
};
if (!serverQueue) {
const queueContruct = {
textChannel: message.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(message.guild.id, queueContruct);
queueContruct.songs.push(song);
try {
var connection = await voiceChannel.join();
queueContruct.connection = connection;
play(message.guild, queueContruct.songs[0]);
} catch (err) {
console.log(err);
queue.delete(message.guild.id);
return message.channel.send(err);
}
} else {
serverQueue.songs.push(song);
return message.channel.send(`${song.title} **by** ${song.author} has been added to the queue!`);
}
}
function skip(message, serverQueue) {
if (!message.member.voice.channel)
return message.channel.send("You have to be in a voice channel to skip audio!");
if (!serverQueue)
return message.channel.send("There is no audio that I could skip!");
serverQueue.connection.dispatcher.end();
}
function stop(message, serverQueue) {
if (!message.member.voice.channel)
return message.channel.send("You have to be in a voice channel to stop audio playback!");
serverQueue.songs = [];
serverQueue.connection.dispatcher.end();
message.channel.send("Successfully stopped audio playback and left voice channel.")
}
function play(guild, song) {
const serverQueue = queue.get(guild.id);
if (!song) {
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
const dispatcher = serverQueue.connection
.play(ytdl(song.url), {bitrate: 192000 /* 192kbps */})
.on("finish", () => {
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
.on("error", error => console.error(error));
dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
serverQueue.textChannel.send(`Started playing: ${song.title} **by** ${song.author}`);
}
The error that I am getting:
(node:262965) UnhandledPromiseRejectionWarning: Error: Unable to retrieve video metadata
at getJSONWatchPage (/media/bitlockermount/My Files/Things I've Made/(Discord Bots)/[AMD]Bot+/node_modules/ytdl-core/lib/info.js:192:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async retryFn (/media/bitlockermount/My Files/Things I've Made/(Discord Bots)/[AMD]Bot+/node_modules/ytdl-core/lib/info.js:136:16)
at async exports.getBasicInfo (/media/bitlockermount/My Files/Things I've Made/(Discord Bots)/[AMD]Bot+/node_modules/ytdl-core/lib/info.js:35:14)
at async exports.getInfo (/media/bitlockermount/My Files/Things I've Made/(Discord Bots)/[AMD]Bot+/node_modules/ytdl-core/lib/info.js:257:14)
at async execute (/media/bitlockermount/My Files/Things I've Made/(Discord Bots)/[AMD]Bot+/bot.js:460:20)
(node:262965) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:262965) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Is this a problem with my code or is it a problem with ytdl-core? It only happens on specific videos.
I am not very good at programming so if I made a mistake please point it out, if you need more info please don’t hesitate to ask.
Sorry for the messy issue layout, I wrote this issue on my phone.
The text was updated successfully, but these errors were encountered:
I am also encountering this error, sometimes waiting resolves it, other times it doesn't, and it appears to happen at random. It also will sometimes resolve itself if I restart my application.
I have a Discord music bot and one of my friends tried to play this video (warning, it is loud): https://youtu.be/ihmDR7W1P1o and it threw an error (sometimes there is no error at all but it still doesn’t play), this does not happen in 3.4.2 however it does happen with version 4 and above.
The audio part of my code:
The error that I am getting:
Is this a problem with my code or is it a problem with ytdl-core? It only happens on specific videos.
I am not very good at programming so if I made a mistake please point it out, if you need more info please don’t hesitate to ask.
Sorry for the messy issue layout, I wrote this issue on my phone.
The text was updated successfully, but these errors were encountered: