mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 22:16:13 +00:00
fix: indicate live track for duration
This commit is contained in:
1 parent
91570e7c2e
commit
0111d3af37
6 files changed
+71
-8
No files matched your search
@@ -82,7 +82,11 @@ module.exports = {
|
||||
})} **\`${timestamp.total.label}\`**`;
|
||||
|
||||
if (currentTrack.raw.duration === 0 || currentTrack.duration === '0:00') {
|
||||
bar = 'No duration available.';
|
||||
bar = '_No duration available._';
|
||||
}
|
||||
|
||||
if (currentTrack.raw.live) {
|
||||
bar = `**\`${embedOptions.icons.liveTrack} LIVE\`** - Playing continuously from live source.`;
|
||||
}
|
||||
|
||||
const nowPlayingActionRow = new ActionRowBuilder().addComponents(
|
||||
@@ -208,6 +212,10 @@ module.exports = {
|
||||
skippedTrack.raw.duration === 0 || skippedTrack.duration === '0:00'
|
||||
? ''
|
||||
: `\`${skippedTrack.duration}\``;
|
||||
|
||||
if (skippedTrack.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
queue.node.skip();
|
||||
|
||||
const repeatModeUserString = loopModesFormatted.get(queue.repeatMode);
|
||||
|
||||
@@ -38,6 +38,10 @@ module.exports = {
|
||||
? ''
|
||||
: `\`${queue.currentTrack.duration}\``;
|
||||
|
||||
if (queue.currentTrack.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
|
||||
// change paused state to opposite of current state
|
||||
queue.node.setPaused(!queue.node.isPaused());
|
||||
logger.debug(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const logger = require('../../services/logger');
|
||||
//const logger = require('../../services/logger');
|
||||
const config = require('config');
|
||||
const embedOptions = config.get('embedOptions');
|
||||
const botOptions = config.get('botOptions');
|
||||
@@ -9,6 +9,12 @@ const { transformQuery } = require('../../utils/validation/searchQueryValidator'
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { useMainPlayer, useQueue } = require('discord-player');
|
||||
|
||||
const logger = require('../../services/logger').child({
|
||||
source: 'play.js',
|
||||
module: 'command',
|
||||
name: '/play'
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
@@ -35,8 +41,6 @@ module.exports = {
|
||||
const searchResults = await player.search(query);
|
||||
let response = [];
|
||||
|
||||
logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: ${query}`);
|
||||
|
||||
response = searchResults.tracks.slice(0, 5).map((track) => {
|
||||
if (track.url.length > 100) {
|
||||
track.url = track.title.slice(0, 100);
|
||||
@@ -54,6 +58,11 @@ module.exports = {
|
||||
return interaction.respond([]);
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
{ action: 'autocomplete_responded' },
|
||||
`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: '${query}'`
|
||||
);
|
||||
|
||||
return interaction.respond(response);
|
||||
},
|
||||
execute: async ({ interaction, client }) => {
|
||||
@@ -82,8 +91,19 @@ module.exports = {
|
||||
requestedBy: interaction.user
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('[Shard ${interaction.guild.shardId}] Failed to search for track with player.search()');
|
||||
logger.error(error);
|
||||
//logger.error('[Shard ${interaction.guild.shardId}] Failed to search for track with player.search()');
|
||||
//logger.error(error);
|
||||
|
||||
logger.error(
|
||||
{
|
||||
error: {
|
||||
message: error.message,
|
||||
type: error.type,
|
||||
stack: error.stack
|
||||
}
|
||||
},
|
||||
`[Shard ${interaction.guild.shardId}] Failed to search for track with player.search() with query: ${transformedQuery}.`
|
||||
);
|
||||
}
|
||||
|
||||
if (!searchResult || searchResult.tracks.length === 0) {
|
||||
@@ -235,16 +255,26 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
if (track.source === 'arbitrary' || !track.thumnail) {
|
||||
if (
|
||||
track.source.length === 0 ||
|
||||
track.source === 'arbitrary' ||
|
||||
track.thumnail === null ||
|
||||
track.thumbnail === undefined ||
|
||||
track.thumbnail === ''
|
||||
) {
|
||||
track.thumbnail =
|
||||
'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/assets/logo-rounded-128px.png';
|
||||
}
|
||||
|
||||
let durationFormat = track.raw.duration === 0 || track.duration === '0:00' ? '' : `\`${track.duration}\``;
|
||||
|
||||
if (track.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
|
||||
if (searchResult.playlist && searchResult.tracks.length > 1) {
|
||||
logger.debug(
|
||||
`[Shard ${interaction.guild.shardId}] Playlist found and added with player.play(). Query: ${query}.`
|
||||
`[Shard ${interaction.guild.shardId}] Playlist found and added with player.play(). Query: '${query}'`
|
||||
);
|
||||
|
||||
return await interaction.editReply({
|
||||
|
||||
@@ -97,6 +97,10 @@ module.exports = {
|
||||
let durationFormat =
|
||||
track.raw.duration === 0 || track.duration === '0:00' ? '' : `\`${track.duration}\``;
|
||||
|
||||
if (track.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
|
||||
return `**${pageIndex * 10 + index + 1}.** **${durationFormat} [${track.title}](${track.url})**`;
|
||||
})
|
||||
.join('\n');
|
||||
@@ -157,6 +161,10 @@ module.exports = {
|
||||
bar = '_No duration available._';
|
||||
}
|
||||
|
||||
if (currentTrack.raw.live) {
|
||||
bar = `**\`${embedOptions.icons.liveTrack} LIVE\`** - Playing continuously from live source.`;
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} and got queue in reply with current track.`
|
||||
);
|
||||
|
||||
@@ -59,6 +59,10 @@ module.exports = {
|
||||
let durationFormat =
|
||||
removedTrack.raw.duration === 0 || removedTrack.duration === '0:00' ? '' : `\`${removedTrack.duration}\``;
|
||||
|
||||
if (removedTrack.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} and removed track.`
|
||||
);
|
||||
|
||||
@@ -58,6 +58,11 @@ module.exports = {
|
||||
skippedTrack.raw.duration === 0 || skippedTrack.duration === '0:00'
|
||||
? ''
|
||||
: `\`${skippedTrack.duration}\``;
|
||||
|
||||
if (skippedTrack.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
|
||||
queue.node.skipTo(skipToTrack - 1);
|
||||
|
||||
logger.debug(
|
||||
@@ -99,6 +104,10 @@ module.exports = {
|
||||
skippedTrack.raw.duration === 0 || skippedTrack.duration === '0:00'
|
||||
? ''
|
||||
: `\`${skippedTrack.duration}\``;
|
||||
|
||||
if (skippedTrack.raw.live) {
|
||||
durationFormat = `\`${embedOptions.icons.liveTrack} LIVE\``;
|
||||
}
|
||||
queue.node.skip();
|
||||
|
||||
const loopModesFormatted = new Map([
|
||||
|
||||
Reference in new issue
Block a user