Динамическое обновление очереди

This commit is contained in:
JonnyBro 2022-08-26 22:23:27 +05:00
parent 045ce8ff8c
commit 9136500baa

View file

@ -35,7 +35,7 @@ class Queue extends BaseCommand {
if (!queue) return interaction.error("music/play:NOT_PLAYING"); if (!queue) return interaction.error("music/play:NOT_PLAYING");
let currentPage = 0; let currentPage = 0;
const embeds = generateQueueEmbed(interaction, queue); let embeds = generateQueueEmbed(interaction, queue);
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
@ -77,6 +77,7 @@ class Queue extends BaseCommand {
if (i.isButton()) { if (i.isButton()) {
if (i.customId === "queue_prev_page") { if (i.customId === "queue_prev_page") {
i.deferUpdate(); i.deferUpdate();
if (embeds != generateQueueEmbed(interaction, queue)) embeds = generateQueueEmbed(interaction, queue);
if (currentPage !== 0) { if (currentPage !== 0) {
--currentPage; --currentPage;
@ -91,6 +92,7 @@ class Queue extends BaseCommand {
} }
} else if (i.customId === "queue_next_page") { } else if (i.customId === "queue_next_page") {
i.deferUpdate(); i.deferUpdate();
if (embeds != generateQueueEmbed(interaction, queue)) embeds = generateQueueEmbed(interaction, queue);
if (currentPage < embeds.length - 1) { if (currentPage < embeds.length - 1) {
currentPage++; currentPage++;
@ -105,6 +107,7 @@ class Queue extends BaseCommand {
} }
} else if (i.customId === "queue_jump_page") { } else if (i.customId === "queue_jump_page") {
i.deferUpdate(); i.deferUpdate();
if (embeds != generateQueueEmbed(interaction, queue)) embeds = generateQueueEmbed(interaction, queue);
const msg = await interaction.followUp({ const msg = await interaction.followUp({
content: interaction.translate("music/queue:PAGE_TO_JUMP", { content: interaction.translate("music/queue:PAGE_TO_JUMP", {