Создаю команду настроек но она выдает много ошибок, долго не могу понять как их исправить, пробовал некоторые способы но они не сработали и стоит ли все это делать в сборщик или стоит попробовать сделать это на мероприятии без сборщика, но тогда я не знаю, как уследить за тем, кто выполнил команду
Команда:
const { SlashCommandBuilder, EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const guild = require('../../database/GuildSchema'); const emoji = require('../../json/emoji.json'); модуль.экспорт = { данные: новый SlashCommandBuilder() .setName('настройки') .setDescription('Показывает текущие настройки сервера и управление ими.'), асинхронное выполнение (клиент, взаимодействие) { const selectMenu = новый StringSelectMenuBuilder() .setCustomId('настройки') .setPlaceholder('Выберите подходящую версию') .addOptions( новый StringSelectMenuOptionBuilder() .setLabel('Цвета') .setEmoji('

') .setDescription('Изменить цвет эмбедов') .setValue('цвет'), ); const deleteButton = новый ButtonBuilder() .setCustomId('удалить-сообщение') .setLabel('Закрыть') .setStyle(ButtonStyle.Danger); константная строка = новый ActionRowBuilder() .addComponents(выбратьМеню); константные кнопки = новый ActionRowBuilder() .addComponents(deleteButton); const startEmbed = новый EmbedBuilder() .setTitle("Ожидается выбор конфигурации") .setDescription(`> Выберите нужное вам меню конфигурации через выбор ниже\n`) .addFields({ name: "Текущая часть:", значение: `Цвет сообщения: \`${(await client.getColor(interaction.guildId)).toString(16)}\`` }) .setColor(ожидайте client.getColor(interaction.guildId)); if (interaction.user.id === interaction.member.user.id) { ждут взаимодействия.ответ({embeds: [startEmbed], компоненты: [строка, кнопки]}); } еще { await Interaction.reply("Извините, только пользователь, вызвавший команду, может использовать эту команду."); } } }; Создание взаимодействия:
const { EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder } = require('discord.js'); const guild = require('../../database/GuildSchema'); const MatrixBotListener = require("../../struct/MatrixBotListener"); класс InteractionCreate расширяет MatrixBotListener { конструктор() { super('InteractionCreateEvent', {событие: 'interactionCreate' }); } асинхронное выполнение (клиент, взаимодействие) { const guildId = Interaction.guildId; const guildConfig = await guild.findOne({id: guildId}); const selectMenu = новый StringSelectMenuBuilder() .setCustomId('настройки') .setPlaceholder('Выберите подходящую версию') .addOptions( новый StringSelectMenuOptionBuilder() .setLabel('Цвета сообщений') .setEmoji('

') .setDescription('Изменить цвет сообщений бота') .setValue('цвет'), ); константная строка = новый ActionRowBuilder() .addComponents(выбратьМеню); const deleteButton = новый ButtonBuilder() .setCustomId('удалить-сообщение') .setLabel('Закрыть') .setStyle(ButtonStyle.Danger); константные кнопки = новый ActionRowBuilder() .addComponents([ новый ButtonBuilder() .setCustomId('назад') .setLabel('Назад') .setStyle(ButtonStyle.Secondary)]) .addComponents([ новый ButtonBuilder() .setCustomId('изменить цвет') .setLabel('Изменить цвет') .setStyle(ButtonStyle.Secondary)]) .addComponents([ новый ButtonBuilder() .setCustomId('цвет сброса') .setLabel('Сбросить') .setStyle(ButtonStyle.Danger) .setDisabled(!guildConfig?.embed_color)]) const delete_Button = новый ActionRowBuilder() .addComponents(deleteButton); пусть colorEmbed = новый EmbedBuilder() .setTitle('Настройка цвета сообщений бота') .setDescription('> Воспользуйтесь кнопками ниже для взаимодействия с меню.\n> Изменение цвета сообщений подразумевает изменение цвета, который отображается слева во всех эмбед сообщениях.\n\n' + 'Вы также можете воспользоваться полезной утилитой [HEX](
https://htmlcolorcodes.com/) для подбора цвета!\n\n' + 'Чтобы изменить цвет, нажмите кнопку "Изменить цвет", затем введите HEX-код цвета в соответствующее поле в модальном окне и подтвердите его.\n\n' + '> Примечание: цвет должен быть в формате HEX (например, #FF0000 для красного цвета), иначе изменение не будет выполнено.') .addFields({ name: "Текущий цвет сообщений:", value: `\`#${(await client.getColor(interaction.guildId)).toString(16)}\`` }) .setColor(await client.getColor(interaction.guildId)); const filter = (i) => i.user.id === interaction.user.id; const collector = interaction.channel.createMessageComponentCollector({ filter: filter, time: 10000 }); let startEmbed = colorEmbed; collector.on('collect', async i => { try { if (i.isStringSelectMenu()) { if (i.values[0] === 'color') { await i.update({embeds: [colorEmbed], components: [buttons]}); } } if (i.customId === 'delete-message') { await i.message.delete(); collector.stop("Сообщение удалено"); return; } if (i.customId === 'back') { const startEmbed = new EmbedBuilder() .setTitle("Ожидается выбор конфигурации") .setDescription(`> Выберите нужную вам конфигурацию через меню выбора ниже\n`) .addFields({ name: "Текущая конфигурация:", value: `Цвет сообщений: ${guildConfig?.embed_color}` }) .setColor(guildConfig?.embed_color || '#4860fa'); await i.editReply({content: "", embeds: [startEmbed], components: [row, delete_Button]}); } if (i.customId === 'reset-color') { await guild.findOneAndDelete({id: guildId}); colorEmbed.data.fields[0].value = `\`стандартный (#4860fa)\``; colorEmbed.data.color = await client.getColor(interaction.guildId); buttons.components[2].setDisabled(true); await i.update({content: "", embeds: [colorEmbed], components: [buttons]}); } if (i.customId === 'change-color') { const id = Math.random().toString(16); i.showModal( new ModalBuilder() .setCustomId(id) .setTitle("Напишите hex код цвета") .addComponents(new ActionRowBuilder() .addComponents( new TextInputBuilder() .setCustomId("color-input") .setLabel("HEX") .setStyle(1) .setMinLength(7) .setMaxLength(7) .setPlaceholder("#fffff") .setRequired(true) ) )).catch(console.error); i.awaitModalSubmit({ filter: (interaction) => interaction.customId === id, time: 60000 }).then(async (modalInteraction) => { const newColor = modalInteraction.fields.getTextInputValue("color-input").replaceAll("#", ""); const isValidHexColor = /^[0-9A-F]{6}$/i.test(newColor); if (!isValidHexColor) { await client.replyErrorHide(modalInteraction, `\`${newColor}\` не является правильным hex кодом цвета.`) return; } await guild.updateOne({id: guildId}, {$set: {embed_color: newColor}}, {upsert: true}); colorEmbed.data.fields[0].value = `\`#${newColor}\`` colorEmbed.data.color = parseInt(newColor, 16) await i.message.edit({embeds: [colorEmbed], components: [buttons]}); await client.replySuccessHide(modalInteraction, `Новый цвет сообщений успешно был установлен`) if (newColor) { buttons.components[2].data.disabled = false; await i.message.edit({embeds: [colorEmbed], components: [buttons]}); } else { buttons.components[2].data.disabled = true; await i.message.edit({embeds: [colorEmbed], components: [buttons]}); } }); } } catch (error) { console.error("Произошла ошибка:", error); await i.reply({ content: "Error...", ephemeral: true }); } }) collector.on('end', async () => { console.log("Время коллектора истекло") collector.stop() await interaction.editReply({components: []}); }) } } module.exports = InteractionCreate; I want to make settings, but when I click on any button I get the following errors:
Произошла ошибка: Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred. at ButtonInteraction.editReply (D:\Кодинг\MatrixBot-git\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:157:48) at InteractionCollector. (D:\Кодинг\MatrixBot-git\src\events\client\interactions.js:97:29) at InteractionCollector.emit (node:events:526:35) at InteractionCollector.handleCollect (D:\Кодинг\MatrixBot-git\node_modules\discord.js\src\structures\interfaces\Collector.js:133:14) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'InteractionNotReplied' } Произошла ошибка: Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred. at ButtonInteraction.editReply (D:\Кодинг\MatrixBot-git\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:157:48) at InteractionCollector. (D:\Кодинг\MatrixBot-git\src\events\client\interactions.js:97:29) at InteractionCollector.emit (node:events:526:35) at InteractionCollector.handleCollect (D:\Кодинг\MatrixBot-git\node_modules\discord.js\src\structures\interfaces\Collector.js:133:14) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'InteractionNotReplied' } 09/20/2023 13:44:49 | [Main thread/ERROR] [ANTI-CRASH] Unhandled Rejection DiscordAPIError[40060]: Interaction has already been acknowledged. at handleErrors (D:\Кодинг\MatrixBot-git\node_modules\@discordjs\rest\dist\index.js:640:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async BurstHandler.runRequest (D:\Кодинг\MatrixBot-git\node_modules\@discordjs\rest\dist\index.js:736:23) at async REST.request (D:\Кодинг\MatrixBot-git\node_modules\@discordjs\rest\dist\index.js

22) at async ButtonInteraction.reply (D:\Кодинг\MatrixBot-git\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5) at async InteractionCollector. (D:\Кодинг\MatrixBot-git\src\events\client\interactions.js:157:17) { requestBody: { files: [], json: { type: 4, data: [Object] } }, rawError: { message: 'Interaction has already been acknowledged.', code: 40060 }, code: 40060, status: 400, method: 'POST', url: '
https://discord.com/api/v10/interaction ... w/callback' } Время коллектора истекло Время коллектора истекло Время коллектора истекло