fix: Better handling of unavailable source after added to queue

This commit is contained in:
Marius Begby committed 2023-12-19 13:01:43 +01:00
1 parent 88511f87c1
commit 69d23d1b77
2 files changed
+23 -2

No files matched your search

+7 -1
View File
@@ -9,9 +9,10 @@ import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
const embedOptions: EmbedOptions = config.get('embedOptions');
const botOptions: BotOptions = config.get('botOptions');
const systemOptions: SystemOptions = config.get('systemOptions');
// Emitted when the player encounters an error while streaming audio track
module.exports = {
name: 'error',
name: 'playerError',
isDebug: false,
isPlayerEvent: true,
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
@@ -24,6 +25,11 @@ module.exports = {
guildId: queue.metadata?.channel.guild.id
});
if (error.message.includes('Could not extract stream for this track')) {
// handled in playerSkip event where we have access to track object
return;
}
logger.error(error, "player.events.on('playerError'): Player error while streaming track");
await queue.metadata?.channel.send({
+16 -1
View File
@@ -34,7 +34,22 @@ module.exports = {
logger.debug(`Track [${track.url}] skipped with reason: ${reason}\n${description}`);
if (reason === TrackSkipReason.NoStream) {
logger.error(`player.events.on('playerSkip'): Failed to play '${track.url}'.\n${description}`);
logger.warn(`player.events.on('playerSkip'): Failed to play '${track.url}'.\n${description}`);
if (description.includes('Could not extract stream for this track')) {
return await queue.metadata?.channel.send({
embeds: [
new EmbedBuilder()
.setDescription(
`**${embedOptions.icons.warning} Oops!**\n` +
`Unable to retrieve audio for the track **[${track.title}](${track.url})**.\n\n` +
'It seems that the source is not available publicly, or the source is not supported.'
)
.setColor(embedOptions.colors.warning)
]
});
}
await queue.metadata?.channel.send({
embeds: [
new EmbedBuilder()