mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
fix: Add track position to footer when track(s) added to queue in /play
This commit is contained in:
1 parent
fa84e2925e
commit
d496945949
4 files changed
+44
-10
No files matched your search
+2
-1
@@ -190,7 +190,8 @@
|
|||||||
"playlistAddedTrackCount_one": "And **1** more track... Use {{queueCommand}} to view all.",
|
"playlistAddedTrackCount_one": "And **1** more track... Use {{queueCommand}} to view all.",
|
||||||
"playlistAddedTrackCount": "And **{{count}}** more tracks... Use {{queueCommand}} to view all.",
|
"playlistAddedTrackCount": "And **{{count}}** more tracks... Use {{queueCommand}} to view all.",
|
||||||
"playlistTooLarge": "{{icon}} **Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **{{count}}**.",
|
"playlistTooLarge": "{{icon}} **Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **{{count}}**.",
|
||||||
"trackNotFound": "{{icon}} **No track found\nNo results found for **{{query}}**.\n\nIf you specified a URL, please make sure it is valid and public."
|
"trackNotFound": "{{icon}} **No track found\nNo results found for **{{query}}**.\n\nIf you specified a URL, please make sure it is valid and public.",
|
||||||
|
"footerAddedPosition": "Added to queue at position {{position}}"
|
||||||
},
|
},
|
||||||
"queue": {
|
"queue": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
+2
-1
@@ -190,7 +190,8 @@
|
|||||||
"playlistAddedTrackCount_one": "Og **1** til låt... Bruk {{queueCommand}} for å se alle.",
|
"playlistAddedTrackCount_one": "Og **1** til låt... Bruk {{queueCommand}} for å se alle.",
|
||||||
"playlistAddedTrackCount": "Og **{{count}}** flere låter... Bruk {{queueCommand}} for å se alle.",
|
"playlistAddedTrackCount": "Og **{{count}}** flere låter... Bruk {{queueCommand}} for å se alle.",
|
||||||
"playlistTooLarge": "{{icon}} **Spilleliste for stor**\nDenne spillelisten er for stor til å legges til i køen.\n\nMaksimalt antall låter som kan legges til i køen er **{{count}}**.",
|
"playlistTooLarge": "{{icon}} **Spilleliste for stor**\nDenne spillelisten er for stor til å legges til i køen.\n\nMaksimalt antall låter som kan legges til i køen er **{{count}}**.",
|
||||||
"trackNotFound": "{{icon}} **Ingen låter funnet**\nIngen resultater funnet for **{{query}}**.\n\nHvis du angav en URL, vær sikker på at den er gyldig og offentlig."
|
"trackNotFound": "{{icon}} **Ingen låter funnet**\nIngen resultater funnet for **{{query}}**.\n\nHvis du angav en URL, vær sikker på at den er gyldig og offentlig.",
|
||||||
|
"footerAddedPosition": "Lagt til i posisjon {{position}} i køen"
|
||||||
},
|
},
|
||||||
"queue": {
|
"queue": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
Vendored
+1
@@ -192,6 +192,7 @@ interface Resources {
|
|||||||
playlistAddedTrackCount: 'And **{{count}}** more tracks... Use {{queueCommand}} to view all.';
|
playlistAddedTrackCount: 'And **{{count}}** more tracks... Use {{queueCommand}} to view all.';
|
||||||
playlistTooLarge: '{{icon}} **Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **{{count}}**.';
|
playlistTooLarge: '{{icon}} **Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **{{count}}**.';
|
||||||
trackNotFound: '{{icon}} **No track found\nNo results found for **{{query}}**.\n\nIf you specified a URL, please make sure it is valid and public.';
|
trackNotFound: '{{icon}} **No track found\nNo results found for **{{query}}**.\n\nIf you specified a URL, please make sure it is valid and public.';
|
||||||
|
footerAddedPosition: 'Added to queue at position {{position}}';
|
||||||
};
|
};
|
||||||
queue: {
|
queue: {
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import { GuildQueue, Player, SearchResult, Track, useMainPlayer, useQueue } from 'discord-player';
|
import { GuildQueue, Player, SearchResult, Track, useMainPlayer, useQueue } from 'discord-player';
|
||||||
import { ChatInputCommandInteraction, EmbedBuilder, GuildMember, Message, SlashCommandBuilder } from 'discord.js';
|
import {
|
||||||
|
ChatInputCommandInteraction,
|
||||||
|
EmbedBuilder,
|
||||||
|
EmbedFooterData,
|
||||||
|
GuildMember,
|
||||||
|
Message,
|
||||||
|
SlashCommandBuilder
|
||||||
|
} from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import { BaseSlashCommandInteraction, CustomError } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction, CustomError } from '../../../classes/interactions';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
@@ -155,6 +162,10 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
const trackUrl = this.getDisplayTrackDurationAndUrl(track, translator);
|
const trackUrl = this.getDisplayTrackDurationAndUrl(track, translator);
|
||||||
|
|
||||||
|
let embedFooter: EmbedFooterData | undefined = this.getDisplayFooterTrackPosition(
|
||||||
|
queue.tracks.data.length ?? 0,
|
||||||
|
translator
|
||||||
|
);
|
||||||
let message =
|
let message =
|
||||||
translator('commands.play.addedToQueueTitle', {
|
translator('commands.play.addedToQueueTitle', {
|
||||||
icon: this.embedOptions.icons.success
|
icon: this.embedOptions.icons.success
|
||||||
@@ -174,6 +185,10 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
count: searchResult.tracks.length,
|
count: searchResult.tracks.length,
|
||||||
queueCommand: formatSlashCommand('queue', translator)
|
queueCommand: formatSlashCommand('queue', translator)
|
||||||
});
|
});
|
||||||
|
if (queue.tracks.data.length != searchResult.tracks.length) {
|
||||||
|
const posistionFirstTrackInPlaylist = queue.tracks.data.length - searchResult.tracks.length + 1;
|
||||||
|
embedFooter = this.getDisplayFooterTrackPosition(posistionFirstTrackInPlaylist, translator);
|
||||||
|
}
|
||||||
} else if (queue.currentTrack === track && queue.tracks.data.length === 0) {
|
} else if (queue.currentTrack === track && queue.tracks.data.length === 0) {
|
||||||
message =
|
message =
|
||||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||||
@@ -181,20 +196,36 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
}) +
|
}) +
|
||||||
'\n' +
|
'\n' +
|
||||||
trackUrl;
|
trackUrl;
|
||||||
|
embedFooter = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||||
|
.setDescription(message)
|
||||||
|
.setThumbnail(this.getTrackThumbnailUrl(track))
|
||||||
|
.setColor(this.embedOptions.colors.success);
|
||||||
|
|
||||||
|
if (embedFooter) {
|
||||||
|
embed.setFooter(embedFooter);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [embed]
|
||||||
new EmbedBuilder()
|
|
||||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
|
||||||
.setDescription(message)
|
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(track))
|
|
||||||
.setColor(this.embedOptions.colors.success)
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getDisplayFooterTrackPosition(position: number, translator: TFunction): EmbedFooterData {
|
||||||
|
const fullFooterData = {
|
||||||
|
text: translator('commands.play.footerAddedPosition', {
|
||||||
|
position: position
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
return fullFooterData;
|
||||||
|
}
|
||||||
|
|
||||||
private async handleNoResultsFound(
|
private async handleNoResultsFound(
|
||||||
transformedQuery: string,
|
transformedQuery: string,
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
|
|||||||
Reference in new issue
Block a user