eu comecei a alterar a parte do configAv para ficar no pique do manage_functions, continue pra mim. Não é pra alterar o manage_functions, ele já tá certo, é só p fzr o configAv ficar no msm estilo tlg


        function formatFunctions(functions) {
            let formatted = '';
            for (const func in functions) {
                formatted += `${func}: \`\`${functions[func]}\`\`\n`;
            }
            return formatted;
        }

        function getFunctionButtons(panelId) {
            return [
                new ActionRowBuilder().addComponents(
                    new ButtonBuilder()
                        .setCustomId(`manage_functions-${panelId}-state-call`)
                        .setEmoji(`<:Lost7Call:1106002914281009322>`)
                        .setLabel(`Criar Call (ON/OFF)`)
                        .setStyle(ButtonStyle.Secondary),
                    new ButtonBuilder()
                        .setCustomId(`manage_functions-${panelId}-state-poke`)
                        .setEmoji(`<a:lb12:1115435692961579140>`)
                        .setLabel(`Poke (ON/OFF)`)
                        .setStyle(ButtonStyle.Secondary),
                    new ButtonBuilder()
                        .setCustomId(`manage_functions-${panelId}-state-assumir`)
                        .setEmoji(`<:verifedLost:1080325994428248174>`)
                        .setLabel(`Assumir (ON/OFF)`)
                        .setStyle(ButtonStyle.Secondary),
                    new ButtonBuilder()
                        .setCustomId(`manage_functions-${panelId}-state-renomear`)
                        .setEmoji(`<:lb4:1113897384909484102>`)
                        .setLabel(`Renomear (ON/OFF)`)
                        .setStyle(ButtonStyle.Secondary),
                    new ButtonBuilder()
                        .setCustomId(`manage_functions-${panelId}-state-pagamento`)
                        .setEmoji(`<:lb11:1113898808519172168>`)
                        .setLabel(`Pagamentos (ON/OFF)`)
                        .setStyle(ButtonStyle.Secondary)
                ),
                new ActionRowBuilder().addComponents(
                    new ButtonBuilder()
                        .setCustomId(`manage_functions-${panelId}-state-genMembro`)
                        .setEmoji(`<:InfoLost7:1106003706467590175>`)
                        .setLabel(`Gerenciar Membros (ON/OFF)`)
                        .setStyle(ButtonStyle.Secondary),
                    new ButtonBuilder()
                        .setCustomId(`returnMainConfig-${panelId}`)
                        .setEmoji(`<:lb7:1113897476651499620>`)
                        .setLabel(`Voltar`)
                        .setStyle(ButtonStyle.Danger)
                ),
            ];
        }

        function toggleFunctionState(panelId, functionName) {
            const { data: panelData, database: panelDB } = getPanelData(panelId);
            if (!panelData) return

            const functionsdb = panelData.functions || {};
            const currentState = functionsdb[functionName] || "Desligado";
            functionsdb[functionName] = currentState === "Ligado" ? "Desligado" : "Ligado";
            panelDB.set(`${panelId}.functions`, functionsdb);
        }

        // FUNCTIONS
        if (interaction.customId.startsWith('manage_functions')) {
            const [, panelId, action, func] = interaction.customId.split('-');
            const { data: panelData, database: panelDB } = getPanelData(panelId);
            if (!panelData) return interaction.reply({ content: `❌ | Painel não encontrado.`, ephemeral: true });

            const functions = panelData.functions

            if (action == 'view') {
                const formattedFunctions = formatFunctions(functions);

                interaction.update({
                    embeds: [
                        new EmbedBuilder()
                            .setTitle(`${interaction.client.user.username} | Gerenciar Ticket`)
                            .setDescription(`⚙ Funções:\n${formattedFunctions}`)
                            .setFooter({
                                text: `${interaction.client.user.username} - Todos os direitos reservados.`,
                                iconURL: interaction.client.user.avatarURL(),
                            }),
                    ],
                    components: getFunctionButtons(panelId),
                });
            } else if (action == 'state') {
                const functionNameMap = {
                    'call': 'CriarCall',
                    'poke': 'Poke',
                    'assumir': 'Assumir',
                    'renomear': 'Renomear',
                    'pagamento': 'Pagamentos',
                    'genMembro': 'GerenciarMembro',
                };

                const functionName = functionNameMap[func];

                if (functionName) {
                    toggleFunctionState(panelId, functionName);
                    const functions = panelDB.get(`${panelId}.functions`);
                    const formattedFunctions = formatFunctions(functions);

                    interaction.update({
                        embeds: [
                            new EmbedBuilder()
                                .setTitle(`${interaction.client.user.username} | Gerenciar Ticket`)
                                .setDescription(`⚙ Funções:\n${formattedFunctions}`)
                                .setFooter({
                                    text: `${interaction.client.user.username} - Todos os direitos reservados.`,
                                    iconURL: interaction.client.user.avatarURL(),
                                }),
                        ],
                        components: getFunctionButtons(panelId),
                    });
                }
            }
        }

        // Configurações Avançadas
        if (interaction.customId.startsWith('config_advanced-')) {
            const [, panelId, action, func] = interaction.customId.split('-');
            const { data: panelData, database: panelDB } = getPanelData(panelId);
            if (!panelData) return interaction.reply({ content: `❌ | Painel não encontrado.`, ephemeral: true });

            const {configsAv} = panelData

            const description = `Escolha abaixo qual das configurações avançadas deseja alterar.\n\nSistema De Modal(Perguntas) - \`\`${configsAv.SistemaModal}\`\`\nSistema de Protocolo(Visual) - \`\`${configsAv.SistemaProtocolo}\`\`\nCategoria Selecionada - \`\`${configsAv.CategoriaSelecionada}\`\``;

            updateAdvancedConfig(interaction, t, description);
        }

        if (interaction.customId === `motivoOnOff`) {
            const configsAv = ticketsBotao.get(`${t.ID}.configsAv`) || {};
            configsAv.SistemaModal = configsAv.SistemaModal === "Ligado" ? "Desligado" : "Ligado";
            ticketsBotao.set(`${t.ID}.configsAv`, configsAv);

            const description = generateAdvancedConfigDescription(configsAv);
            updateAdvancedConfig(interaction, t, description);
        }

        if (interaction.customId === `protocoloOnOff`) {
            const configsAv = ticketsBotao.get(`${t.ID}.configsAv`) || {};
            configsAv.SistemaProtocolo = configsAv.SistemaProtocolo === "Ligado" ? "Desligado" : "Ligado";
            ticketsBotao.set(`${t.ID}.configsAv`, configsAv);

            const description = generateAdvancedConfigDescription(configsAv);
            updateAdvancedConfig(interaction, t, description);
        }

        if (interaction.customId === `selCategori`) {
            const configsAv = ticketsBotao.get(`${t.ID}.configsAv`) || {};
            configsAv.CategoriaSelecionada = configsAv.CategoriaSelecionada === "Ligado" ? "Desligado" : "Ligado";
            ticketsBotao.set(`${t.ID}.configsAv`, configsAv);

            const description = generateAdvancedConfigDescription(configsAv);
            updateAdvancedConfig(interaction, t, description);
        }

        if (interaction.customId === `configCargo`) {
            const permissoes = ticketsBotao.get(`${t.ID}.permissoes`) || {};
            const cargosSelecionados = getFormattedRoleMentions(permissoes);
            sendPermissoesResponse(interaction, t, cargosSelecionados);
        }

        if (interaction.customId === `permRo`) {
            const selectedRoles = interaction.values;
            const permissoes = updatePermissoes(t.ID, selectedRoles);
            const cargosSelecionados = getFormattedRoleMentions(permissoes);
            sendPermissoesResponse(interaction, t, cargosSelecionados);
        }

        // Funções auxiliares

        function getFormattedRoleMentions(permissoes) {
            if (permissoes && Object.keys(permissoes).length > 0) {
                return Object.keys(permissoes)
                    .map((roleId) => `<@&${roleId}>`)
                    .join("\n");
            } else {
                return "Nenhum cargo selecionado.";
            }
        }

        function updatePermissoes(ticketId, selectedRoles) {
            let permissoes = ticketsBotao.get(`${ticketId}.permissoes`) || {};

            selectedRoles.forEach((roleId) => {
                const roleIdString = roleId.toString();
                if (permissoes[roleIdString]) {
                    delete permissoes[roleIdString]; // Remove o cargo se já estiver selecionado
                } else {
                    permissoes[roleIdString] = true; // Adiciona o cargo se não estiver selecionado
                }
            });

            ticketsBotao.set(`${ticketId}.permissoes`, permissoes);
            return permissoes;
        }

        function sendPermissoesResponse(interaction, t, cargosSelecionados) {
            interaction.update({
                embeds: [
                    new EmbedBuilder()
                        .setTitle(`${interaction.client.user.username} | Gerenciar Ticket`)
                        .setDescription(`Cargos Selecionados:\n\n${cargosSelecionados}`)
                        .setFooter({
                            text: `${interaction.client.user.username} - Todos os direitos reservados.`,
                            iconURL: interaction.client.user.avatarURL(),
                        }),
                ],
                components: [
                    new ActionRowBuilder().addComponents(
                        new RoleSelectMenuBuilder()
                            .setCustomId(`permRoles-${t.ID}`)
                            .setPlaceholder("Selecione qual cargo terá permissões no ticket.")
                            .setMaxValues(10)
                    ),
                    new ActionRowBuilder().addComponents(
                        new ButtonBuilder()
                            .setCustomId(`returnMainConfig-${t.ID}`)
                            .setEmoji("<:lb7:1113897476651499620>") // Emoji mantido
                            .setLabel("Voltar")
                            .setStyle(ButtonStyle.Danger)
                    ),
                ],
            });
        }


        // Funções Auxiliares Adicionais

        function generateAdvancedConfigDescription(configsAv) {
            return `Escolha abaixo qual das configurações avançadas deseja alterar.\n\nSistema De Modal(Perguntas) - \`\`${configsAv.SistemaModal}\`\`\nSistema de Protocolo(Visual) - \`\`${configsAv.SistemaProtocolo}\`\`\nCategoria Selecionada - \`\`${configsAv.CategoriaSelecionada}\`\``;
        }

        function updateAdvancedConfig(interaction, description) {
            interaction.update({
                embeds: [
                    new EmbedBuilder()
                        .setTitle(`${interaction.client.user.username} | Gerenciar Ticket`)
                        .setDescription(description)
                        .setFooter({
                            text: `${interaction.client.user.username} - Todos os direitos reservados.`,
                            iconURL: interaction.client.user.avatarURL(),
                        }),
                ],
                components: [
                    new ActionRowBuilder().addComponents(
                        new ButtonBuilder()
                            .setCustomId(`altButton-${t.ID}`)
                            .setEmoji("<:lb4:1113897384909484102>")
                            .setLabel("Alterar Button")
                            .setStyle(ButtonStyle.Secondary),
                        new ButtonBuilder()
                            .setCustomId(`configCargo-${t.ID}`)
                            .setEmoji("<:InfoLost7:1106003706467590175>")
                            .setLabel("Configurar Cargos")
                            .setStyle(ButtonStyle.Secondary),
                        new ButtonBuilder()
                            .setCustomId(`motivoOnOff-${t.ID}`)
                            .setEmoji("<:TeamLostt7:1106818257484255232>")
                            .setLabel("Motivo da Abertura (ON/OFF)")
                            .setStyle(ButtonStyle.Secondary),
                        new ButtonBuilder()
                            .setCustomId(`selCategoria-${t.ID}`)
                            .setEmoji("<:FixLost7:1105692591820898344>")
                            .setLabel("Selecionar uma Categoria")
                            .setStyle(ButtonStyle.Secondary),
                        new ButtonBuilder()
                            .setCustomId(`protocoloOnOff-${t.ID}`)
                            .setEmoji("<:pastalosts22:1080325485101338695>")
                            .setLabel("Sistema de Protocolo (ON/OFF)")
                            .setStyle(ButtonStyle.Secondary)
                    ),
                    new ActionRowBuilder().addComponents(
                        new ButtonBuilder()
                            .setCustomId(`returnMainConfig-${t.ID}`)
                            .setEmoji("<:lb7:1113897476651499620>")
                            .setLabel("Voltar")
                            .setStyle(ButtonStyle.Danger)
                    ),
                ],
            });
        }