Skip to content

Commit

Permalink
fix: add error listener to discord-player
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirasaki committed Dec 1, 2023
1 parent 4f74bd2 commit 6d28619
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/music-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
} = require('./util');
const { EmbedBuilder, escapeMarkdown } = require('discord.js');
const { getGuildSettings } = require('./modules/db');
const { MS_IN_ONE_SECOND } = require('./constants');
const { MS_IN_ONE_SECOND, EMBED_DESCRIPTION_MAX_LENGTH } = require('./constants');

module.exports = (player) => {
// this event is emitted whenever discord-player starts to play a track
Expand All @@ -22,6 +22,17 @@ module.exports = (player) => {
] });
});

player.events.on('error', (queue, error) => {
// Emitted when the player encounters an error
queue.metadata.channel.send({ embeds: [
{
color: colorResolver(),
title: 'Player Error',
description: error.message.slice(0, EMBED_DESCRIPTION_MAX_LENGTH)
}
] });
});

player.events.on('playerError', (err) => {
logger.syserr('Music Player encountered unexpected error:');
logger.printErr(err);
Expand Down

0 comments on commit 6d28619

Please sign in to comment.