melhore esse código

const Command = require("../../structures/Command");
const { PermissionsBitField, ApplicationCommandOptionType, EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder } = require("discord.js")
const wio = require("wio.db");

const ticketsBotao = new wio.JsonDatabase({ databasePath: `src/database/ticketsBotao.json` });

module.exports = class extends Command {
    constructor(client) {
        super(client, {
            name: "set",
            description: "Envie o ticket no canal",
            default_member_permissions: PermissionsBitField.Flags.Administrator,
            slash: true,
            options: [
                {
                    name: "id",
                    type: ApplicationCommandOptionType.String,
                    description: "ID do seu ticket",
                    autocomplete: true,
                    required: true,
                },
            ],
        });
    }

    autocomplete = async (interaction) => {
        const focusedOption = interaction.options.getFocused(true);
        let choices;

        if (focusedOption.name === `id`) {
            const choicesMain = [];

            const all = ticketsBotao.all();

            if (all.length < 1) {
                choicesMain.push(`Nenhum ticket criado!`);
            } else {
                all.map((p) => {
                    choicesMain.push(p.ID);
                });
            }

            choices = choicesMain;
        }

        const filtered = choices.filter((choice) =>
            choice.startsWith(focusedOption.value)
        );
        await interaction.respond(
            filtered.map((choice) => ({
                name: `ID - ${choice} | Nome - ${ticketsBotao.get(
                    `${choice}.nome`
                )}`,
                value: choice,
            }))
        );
    };

    run = async (interaction) => {
        const botConfig = new wio.JsonDatabase({
            databasePath: `src/database/botConfig.json`,
        });

        const usersPerms = botConfig.get("usersPerms") || [];

        if (!usersPerms.includes(interaction.user.id)) {
            return interaction.reply({
                content: `**❌ | Você não tem permissão.**`,
                ephemeral: true,
            });
        }

        const id = interaction.options.getString(`id`);

        const embed = new EmbedBuilder()
            .setFooter({
                text: ticketsBotao.get(`${id}.configs.footer`) || null,
            })
            .setTitle(
                `${ticketsBotao.get(`${id}.configs.titulo`) ||
                `${this.client.user.username} | ${interaction.guild.name} | Sistema de Ticket`
                }`
            )
            .setDescription(
                `${ticketsBotao.get(`${id}.configs.descricao`) ||
                `:arrow_forward: Clique abaixo para abrir um TICKET na categoria \`\`Não configurado ainda...\`\``
                }`
            );

        if (ticketsBotao.get(`${id}.configs.banner`)) {
            embed.setImage(ticketsBotao.get(`${id}.configs.banner`));
        }

        if (ticketsBotao.get(`${id}.configs.miniatura`)) {
            embed.setThumbnail(ticketsBotao.get(`${id}.configs.miniatura`));
        }

        let buttonStyle;

        const color = ticketsBotao.get(`${id}.buttonConfig.color`);

        const buttonStyles = {
            "Azul": ButtonStyle.Primary,
            "Vermelho": ButtonStyle.Danger,
            "Verde": ButtonStyle.Success,
            "Cinza": ButtonStyle.Secondary,
        };

        buttonStyle = buttonStyles[color];

        interaction.reply({
            content: `**✅ | Painel enviado com sucesso.**`,
            ephemeral: true,
        });

        if (buttonStyle) {
            interaction.channel
                .send({
                    embeds: [embed],
                    components: [
                        new ActionRowBuilder().addComponents(
                            new ButtonBuilder()
                                .setCustomId(`abrirTicket-${id}`)
                                .setLabel(
                                    `${ticketsBotao.get(
                                        `${id}.buttonConfig.label`
                                    ) || "Abrir Ticket"
                                    }`
                                )
                                .setEmoji(
                                    `${ticketsBotao.get(
                                        `${id}.buttonConfig.emoji`
                                    ) || "👋"
                                    }`
                                )
                                .setStyle(buttonStyle)
                        ),
                    ],
                })
                .then((msg) => {
                    ticketsBotao.set(`${id}.msgId`, msg.id);
                    ticketsBotao.set(`${id}.channelId`, interaction.channel.id);
                });
        } else {
            console.error("Estilo de botão inválido:", color);
        }
    };
};