mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
fix: Better handling of unavailable source after added to queue
This commit is contained in:
1 parent
88511f87c1
commit
69d23d1b77
2 files changed
+23
-2
No files matched your search
@@ -9,9 +9,10 @@ import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
|||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const botOptions: BotOptions = config.get('botOptions');
|
const botOptions: BotOptions = config.get('botOptions');
|
||||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||||
|
|
||||||
// Emitted when the player encounters an error while streaming audio track
|
// Emitted when the player encounters an error while streaming audio track
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'error',
|
name: 'playerError',
|
||||||
isDebug: false,
|
isDebug: false,
|
||||||
isPlayerEvent: true,
|
isPlayerEvent: true,
|
||||||
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
|
execute: async (queue: ExtendedGuildQueuePlayerNode, error: Error) => {
|
||||||
@@ -24,6 +25,11 @@ module.exports = {
|
|||||||
guildId: queue.metadata?.channel.guild.id
|
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");
|
logger.error(error, "player.events.on('playerError'): Player error while streaming track");
|
||||||
|
|
||||||
await queue.metadata?.channel.send({
|
await queue.metadata?.channel.send({
|
||||||
|
|||||||
@@ -34,7 +34,22 @@ module.exports = {
|
|||||||
logger.debug(`Track [${track.url}] skipped with reason: ${reason}\n${description}`);
|
logger.debug(`Track [${track.url}] skipped with reason: ${reason}\n${description}`);
|
||||||
|
|
||||||
if (reason === TrackSkipReason.NoStream) {
|
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({
|
await queue.metadata?.channel.send({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
|
|||||||
Reference in new issue
Block a user