mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
fix(playerSkip): only log on error
This commit is contained in:
1 parent
29a759b28d
commit
f5a39f430e
1 file changed
+13
-5
@@ -1,5 +1,5 @@
|
||||
import config from 'config';
|
||||
import { Track } from 'discord-player';
|
||||
import { Track, TrackSkipReason } from 'discord-player';
|
||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import { Logger } from 'pino';
|
||||
@@ -10,12 +10,18 @@ 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 audio player fails to load the stream for a track
|
||||
|
||||
// Emitted when the audio player skips a track.
|
||||
module.exports = {
|
||||
name: 'playerSkip',
|
||||
isDebug: false,
|
||||
isPlayerEvent: true,
|
||||
execute: async (queue: ExtendedGuildQueuePlayerNode, track: Track) => {
|
||||
execute: async (
|
||||
queue: ExtendedGuildQueuePlayerNode,
|
||||
track: Track,
|
||||
reason: TrackSkipReason,
|
||||
description: string
|
||||
) => {
|
||||
const executionId: string = uuidv4();
|
||||
const logger: Logger = loggerModule.child({
|
||||
module: 'event',
|
||||
@@ -25,8 +31,10 @@ module.exports = {
|
||||
guildId: queue.metadata?.channel.guild.id
|
||||
});
|
||||
|
||||
logger.error(`player.events.on('playerSkip'): Failed to play '${track.url}'.`);
|
||||
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}`);
|
||||
await queue.metadata?.channel.send({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@@ -37,7 +45,6 @@ module.exports = {
|
||||
.setFooter({ text: `Execution ID: ${executionId}` })
|
||||
]
|
||||
});
|
||||
|
||||
if (systemOptions.systemMessageChannelId && systemOptions.systemUserId) {
|
||||
const channel: BaseGuildTextChannel = (await queue.metadata?.client.channels.cache.get(
|
||||
systemOptions.systemMessageChannelId
|
||||
@@ -57,4 +64,5 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user