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