From a945f42802571ce2d0e340ccafc4067d63a84a5b Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Tue, 21 Nov 2023 01:19:46 +0500 Subject: [PATCH] autoupdate nowplaying every 2 minutes --- commands/Music/nowplaying.js | 13 ++++++++++++- events/CommandHandler.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index a9c99647..aed15dfb 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -205,10 +205,21 @@ class Nowplaying extends BaseCommand { const embed = await updateEmbed(interaction, queue); - interaction.editReply({ + const message = await interaction.editReply({ embeds: [embed], components: [row1, row2], }); + + const i = setInterval(async function () { + if (message && message.editable && queue.isPlaying()) { + const e = await updateEmbed(interaction, queue); + + message.edit({ + embeds: [e], + components: [row1, row2], + }); + } else clearInterval(i); + }, 2 * 60 * 1000); } } diff --git a/events/CommandHandler.js b/events/CommandHandler.js index 723538ac..fd7c69da 100644 --- a/events/CommandHandler.js +++ b/events/CommandHandler.js @@ -29,7 +29,7 @@ class CommandHandler extends BaseEvent { data.memberData = memberData; } - if (command.dirname.includes("IAT") && interaction.guildId !== "1039187019957555252") return interaction.reply({ content: "IAT Only", ephemeral: true }); + if (command?.dirname.includes("IAT") && interaction.guildId !== "1039187019957555252") return interaction.reply({ content: "IAT Only", ephemeral: true }); if (interaction.isAutocomplete()) return await command.autocompleteRun(client, interaction); if (interaction.isButton() && interaction.customId === "quote_delete" && interaction.message.deletable) return interaction.message.delete(); if (interaction.type !== InteractionType.ApplicationCommand && !interaction.isCommand()) return;