diff --git a/src/events/player/playerError.ts b/src/events/player/playerError.ts index 08c4077..99d100c 100644 --- a/src/events/player/playerError.ts +++ b/src/events/player/playerError.ts @@ -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({ diff --git a/src/events/player/playerSkip.ts b/src/events/player/playerSkip.ts index fa64c64..bfa36af 100644 --- a/src/events/player/playerSkip.ts +++ b/src/events/player/playerSkip.ts @@ -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()