'Discord.js V13 Interaction Failed

I'm creating a ticket bot for discord, the interaction of the buttons works well, but when I press "Cancelar Fechamento", it returns "interaction failed", but the button works normally, could you help me to solve it? I don't find any solution for this, I already tried some alternatives like deferUpdate(), but it didn't solve my problem.

let hastebin = require('hastebin');
let randomstring = require("randomstring");

module.exports = {
  name: 'interactionCreate',
  async execute(interaction, client) {

    const randomid = randomstring.generate({
      length: 5,
      charset: 'numeric',
      capitalization: 'lowercase'
    });

    if (!interaction.isButton()) return;
    if (interaction.customId == "open-ticket") {
      if (client.guilds.cache.get(interaction.guildId).channels.cache.find(c => c.topic == interaction.user.id)) {
        return interaction.reply({
          content: 'Você já possui um ticket aberto!',
          ephemeral: true
        });
      };

      interaction.guild.channels.create(`ticket-${randomid}`, {
        parent: client.config.parentOpened,
        topic: interaction.user.id,
        permissionOverwrites: [{
            id: interaction.user.id,
            allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
          },
          {
            id: client.config.roleSupport,
            allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
          },
          {
            id: interaction.guild.roles.everyone,
            deny: ['VIEW_CHANNEL'],
          },
        ],
        type: 'text',
      }).then(async c => {
        interaction.reply({
          content: `Ticket Criado em: <#${c.id}>`,
          ephemeral: true
        });

        const embed = new client.discord.MessageEmbed()
          .setColor('#7121cc')
          .setAuthor('Criar um Ticket', client.user.avatarURL())
          .setDescription('Olá, está precisa de ajuda? se sim, por favor, selecione a categoria do seu ticket abaixo e aguarde alguns instantes até que um membro de nossa equipe possa lhe atender!\n\n> O Atendimento é feito de segunda a domingo, caso não possua um membro da equipe online, você pode aguardar por uma resposta! \n >  \n> Aos fins de semana, o atendimento pode demorar um pouco devido ao fluxo de tickets.\n\n Por favor, selecione a categoria correta de acordo com o seu problema!');

        const row = new client.discord.MessageActionRow()
          .addComponents(
            new client.discord.MessageSelectMenu()
            .setCustomId('category')
            .setPlaceholder('Selecione a Categoria do Ticket!')
            .addOptions([{
                label: 'Financeiro',
                description: 'Para problemas com pagamentos ou envio de comprovantes!',
                value: 'financeiro',
                emoji: '<:h_pix:952341304447205436>',
              },
              {
                label: 'Suporte',
                description: 'Para sanar dúvidas com o nosso suporte técnico!',
                value: 'suporte',
                emoji: '<:suporte:953997788709015552>',
              },
              {
                label: 'Denuncias',
                description: 'Para realizar denuncias ou solicitar revisões de banimentos!',
                value: 'denuncias',
                emoji: '<:bans:953997240551243796>',
              },
              {
                label: 'Organizações',
                description: 'Para tratar de assuntos referentes a Facções/Corporações!',
                value: 'organizacoes',
                emoji: '<:orgs:953998085258879036>',
              },
              {
                label: 'Mods/Privados',
                description: 'Para tratar de assuntos referentes a Mods e Privados!',
                value: 'privados',
                emoji: '<:privados:953996888795910194>',
              },
            ]),
          );

        msg = await c.send({
          content: `<@!${interaction.user.id}>`,
          embeds: [embed],
          components: [row]
        });

        const collector = msg.createMessageComponentCollector({
          componentType: 'SELECT_MENU',
          time: 30000
        });

        collector.on('collect', i => {
          if (i.user.id === interaction.user.id) {
            if (msg.deletable) {
              msg.delete().then(async () => {
                const embed = new client.discord.MessageEmbed()
                  .setColor('#7121cc')
                  .setAuthor('Criar um Ticket', client.user.avatarURL())
                  .setDescription(`<@!${interaction.user.id}> Criou um Ticket ${i.values[0]}`)
                  .setFooter('devPhytols', client.user.avatarURL())
                  .setTimestamp();

                const row = new client.discord.MessageActionRow()
                  .addComponents(
                    new client.discord.MessageButton()
                    .setCustomId('close-ticket')
                    .setLabel('Fechar Ticket')
                    .setEmoji('899745362137477181')
                    .setStyle('DANGER'),
                  );

                const opened = await c.send({
                  content: `<@&${client.config.roleSupport}>`,
                  embeds: [embed],
                  components: [row]
                });

                opened.pin().then(() => {
                  opened.channel.bulkDelete(1);
                });
              });
            };
            if (i.values[0] == 'financeiro') {
              c.edit({
                parent: client.config.parentTransactions
              });
            };
            if (i.values[0] == 'suporte') {
              c.edit({
                parent: client.config.parentJeux
              });
            };
            if (i.values[0] == 'denuncias') {
              c.edit({
                parent: client.config.parentAutres
              });
            };
            if (i.values[0] == 'organizacoes') {
              c.edit({
                parent: client.config.ticketsorganizacoes
              });
            };
            if (i.values[0] == 'privados') {
              c.edit({
                parent: client.config.ticketsprivados
              });
            };
          };
        });

        collector.on('end', collected => {
          if (collected.size < 1) {
            c.send(`Nenhuma categoria foi selecionada! Fechando o ticket...`).then(() => {
              setTimeout(() => {
                if (c.deletable) {
                  c.delete();
                };
              }, 5000);
            });
          };
        });
      });
    };

    if (interaction.customId == "close-ticket") {
      const guild = client.guilds.cache.get(interaction.guildId);
      const chan = guild.channels.cache.get(interaction.channelId);

      const row = new client.discord.MessageActionRow()
        .addComponents(
          new client.discord.MessageButton()
          .setCustomId('confirm-close')
          .setLabel('Fechar o Ticket')
          .setStyle('DANGER'),
          new client.discord.MessageButton()
          .setCustomId('no')
          .setLabel('Cancelar Fechamento')
          .setStyle('SECONDARY'),
        );
        const row2 = new client.discord.MessageActionRow()
        .addComponents(
          new client.discord.MessageButton()
          .setCustomId('close-ticket')
          .setLabel('Fechar o Ticket')
          .setStyle('DANGER'),
        );

        const verif = await interaction.update({
          content: 'Tem certeza de que deseja fechar o ticket?',
          components: [row]
        });

      const collector = interaction.channel.createMessageComponentCollector({
        componentType: 'BUTTON',
        time: 3000
      });

      collector.on('collect', i => {
        if (i.customId == 'confirm-close') {
          interaction.editReply({
            content: `Ticket fechado por: <@!${interaction.user.id}>`,
            components: []
          });
          collector.stop();
          chan.edit({
              name: `closed-${chan.name}`,
              permissionOverwrites: [{
                  id: client.users.cache.get(chan.topic),
                  deny: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                  id: client.config.roleSupport,
                  deny: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                  id: interaction.guild.roles.everyone,
                  deny: ['VIEW_CHANNEL'],
                },
              ],
            })
            .then(async () => {
              const embed = new client.discord.MessageEmbed()
                .setColor('#7121cc')
                .setDescription('```Ticket Fechado!```')
                .setTimestamp();

              chan.send({
                embeds: [embed],

              });
            });
        };

        if (i.customId == 'no') {
          interaction.editReply({
            content: `<@&${client.config.roleSupport}> Ticket reaberto!`,
            components: [row2]
          });
        };
      });

      collector.on('end', (i) => {
        if (i.size < 1) {
          interaction.editReply({
            content: `<@&${client.config.roleSupport}>`,
            components: [row]
          });
        };
      });
    };

    if (interaction.customId == "confirm-close") {
      const guild = client.guilds.cache.get(interaction.guildId);
      const chan = guild.channels.cache.get(interaction.channelId);

      chan.messages.fetch().then(async (messages) => {
        let a = messages.filter(m => m.author.bot !== true).map(m =>
          `${new Date(m.createdTimestamp).toLocaleString('fr-FR')} - ${m.author.username}#${m.author.discriminator}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`
        ).reverse().join('\n');
        if (a.length < 1) a = "Nenhuma Mensagem"
        hastebin.createPaste(a, {
            contentType: 'text/plain',
            server: 'https://hastebin.com'
          }, {})
          .then(function (urlToPaste) {
            const embed = new client.discord.MessageEmbed()
              .setAuthor('Logs de Tickets', client.user.avatarURL())
              .setDescription(`📰 | Logs do ticket \`${chan.id}\`\n<:setagreen:954000627237789756> | Criado por <@!${chan.topic}>\n<:setared:954000627334266920> | Fechado por <@!${interaction.user.id}>\n\nLogs: [**Clique aqui para ver as mensagens!**](${urlToPaste})`)
              .setColor('#7121cc')
              .setTimestamp();
              const embedclosedticket = new client.discord.MessageEmbed()
              .setDescription(`***Ticket Fechado! Enviando logs para o sistema...***`)
              .setColor('#e02b2b')
            client.channels.cache.get(client.config.logsTicket).send({
              embeds: [embed]
            });
            chan.send({
              embeds: [embedclosedticket]
            });
            chan.edit({
              permissionOverwrites: [{
                  id: client.users.cache.get(chan.topic),
                  deny: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                  id: client.config.roleSupport,
                  deny: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                  id: interaction.guild.roles.everyone,
                  deny: ['VIEW_CHANNEL'],
                },
              ],
            })

            setTimeout(() => {
              chan.delete();
            }, 5000);
          });
      });
    };
  },
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source