mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-24 18:41:57 +01:00
🐛 Fix interaction id in page data map for playlist command
This commit is contained in:
parent
1632c2345e
commit
99cbbf4850
@ -57,11 +57,11 @@ export class PlaylistCommand {
|
||||
): Promise<void> {
|
||||
const page = dto.page ?? 0;
|
||||
|
||||
const response = await interaction.reply(
|
||||
await interaction.reply(
|
||||
this.getReplyForPage(page) as InteractionReplyOptions,
|
||||
);
|
||||
|
||||
this.pageData.set(response.id, page);
|
||||
this.pageData.set(interaction.id, page);
|
||||
this.logger.debug(
|
||||
`Added '${interaction.id}' as a message id for page storage`,
|
||||
);
|
||||
@ -70,6 +70,7 @@ export class PlaylistCommand {
|
||||
this.logger.log(
|
||||
`Removed the components of message from interaction '${interaction.id}' because the event collector has reachted the timeout`,
|
||||
);
|
||||
this.pageData.delete(interaction.id);
|
||||
await interaction.editReply({
|
||||
components: [],
|
||||
});
|
||||
@ -156,15 +157,26 @@ export class PlaylistCommand {
|
||||
chunks: Track[][],
|
||||
page: number,
|
||||
): EmbedBuilder | undefined {
|
||||
this.logger.verbose(
|
||||
`Received request for page ${page} of playlist page chunks`,
|
||||
);
|
||||
const playlist = this.playbackService.getPlaylistOrDefault();
|
||||
|
||||
if (page >= chunks.length || page < 0) {
|
||||
this.logger.warn(`Request for page chunks was out of range: ${page}`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const offset = page * 10;
|
||||
const chunk = chunks[page];
|
||||
|
||||
const content = chunks[page]
|
||||
if (!chunk) {
|
||||
this.logger.error(
|
||||
`Failed to extract chunk from playlist chunks array with page ${page}`,
|
||||
);
|
||||
}
|
||||
|
||||
const content = chunk
|
||||
.map((track, index) => {
|
||||
const isCurrent = track === playlist.getActiveTrack();
|
||||
|
||||
|
@ -36,6 +36,9 @@ export class PlaylistInteractionCollector {
|
||||
@On('collect')
|
||||
async onCollect(interaction: ButtonInteraction): Promise<void> {
|
||||
const targetPage = this.getInteraction(interaction);
|
||||
this.logger.verbose(
|
||||
`Extracted the target page ${targetPage} from the button interaction`,
|
||||
);
|
||||
|
||||
if (targetPage === undefined) {
|
||||
await interaction.update({
|
||||
@ -55,6 +58,13 @@ export class PlaylistInteractionCollector {
|
||||
private getInteraction(interaction: ButtonInteraction): number | null {
|
||||
const current = this.playlistCommand.pageData.get(this.causeInteraction.id);
|
||||
|
||||
if (current === undefined) {
|
||||
this.logger.warn(
|
||||
`Unable to extract the current page from the cause interaction '${this.causeInteraction.id}'`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
this.logger.debug(
|
||||
`Retrieved current page from command using id '${
|
||||
this.causeInteraction.id
|
||||
|
@ -3,7 +3,7 @@ export const Constants = {
|
||||
Version: {
|
||||
Major: 0,
|
||||
Minor: 0,
|
||||
Patch: 4,
|
||||
Patch: 5,
|
||||
All: () =>
|
||||
`${Constants.Metadata.Version.Major}.${Constants.Metadata.Version.Minor}.${Constants.Metadata.Version.Patch}`,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user