User: sempurnakan kode ini agar dia bisa otomatis menghapus output yang telah di hasilkan import fs from "fs";
import path from "path";
import axios from "axios";
import { execSync } from "child_process";
import fetch from "node-fetch";
import { addExif } from "../lib/sticker.js";
import { Sticker } from "wa-sticker-formatter";

let cooldown = new Map();

let handler = async (a, { conn: r, args: e }) => {
    var t = a.sender;
    let o;

    if (1 <= e.length) {
        o = e.join(" ");
    } else {
        if (!a.quoted || !a.quoted.text) return r.reply(a.chat, "Input atau reply text!", a);
        o = a.quoted.text;
    }

    if (!o) return r.reply(a.chat, "Contoh penggunaan: !bratvideo hello world", a);
    if (250 < o.length) return r.reply(a.chat, "Max 250 karakter!", a);

    if (cooldown.has(t)) {
        e = cooldown.get(t);
        e = (Date.now() - e) / 1e3;
        if (e < 10) return a.reply(`[❗] Tunggu ${Math.ceil(10 - e)} detik sebelum menggunakan perintah ini lagi.`);
    }

    cooldown.set(t, Date.now());
    r.sendReact(a.chat, "🕒", a.key);

    var n = o.split(" ");
    var i = path.resolve("tmp");
    var s = (fs.existsSync(i) || fs.mkdirSync(i), []);

    try {
        for (let e = 0; e < n.length; e++) {
            var p = n.slice(0, e + 1).join(" ");
            var c = await axios.get("https://brat.caliphdev.com/api/brat?text=" + encodeURIComponent(p), { responseType: "arraybuffer" }).catch(e => e.response);
            var l = path.join(i, `frame${e}.mp4`);
            fs.writeFileSync(l, c.data);
            s.push(l);
        }

        var f = path.join(i, "filelist.txt");
        let t = "";
        for (let e = 0; e < s.length; e++) {
            t += `file '${s[e]}'
duration 0.7
`;
        }
        t += `file '${s[s.length - 1]}'
duration 2
`;
        fs.writeFileSync(f, t);

        var h = path.join(i, "output.mp4");
        var d = execSync(`ffmpeg -y -f concat -safe 0 -i ${f} -vf "fps=30" -c:v libx264 -preset ultrafast -pix_fmt yuv420p ` + h);
        var videoBuffer = fs.readFileSync(h);
        var m = await mp4ToWebp(videoBuffer, { pack: global.packname, author: global.author });

        r.sendFile(a.chat, m, "sticker.webp", o, a);
        s.forEach(e => { fs.existsSync(e) && fs.unlinkSync(e); });
        fs.existsSync(f) && fs.unlinkSync(f);
        fs.existsSync(h) && fs.unlinkSync(h);
    } catch (e) {
        r.reply(a.chat, `Terjadi kesalahan saat membuat stiker.\n- ${e.message}`, a);
    }
};

async function mp4ToWebp(buffer, options) {
    options = options || { pack: "‎", author: "‎", crop: false };
    const data = {
        file: "data:video/mp4;base64," + buffer.toString("base64"),
        processOptions: {
            crop: options.crop,
            startTime: "00:00:00.0",
            endTime: "00:00:07.0",
            loop: 0
        },
        stickerMetadata: { ...options }
    };

    const response = await fetch("https://sticker-api.openwa.dev/convertMp4BufferToWebpDataUrl", {
        method: "POST",
        headers: {
            Accept: "application/json, text/plain, */*",
            "Content-Type": "application/json;charset=utf-8"
        },
        body: JSON.stringify(data)
    });

    return Buffer.from((await response.text()).split(";base64,")[1], "base64");
}

handler.help = handler.command = ["bratvideo"];
handler.tags = ["tools"];
export default handler; dan tolong sempurnakan informasi errornya maaf terjadi kesalahan saat mengambil output
User: sempurnakan kode ini agar dia bisa otomatis menghapus output yang telah di hasilkan import fs from "fs";
import path from "path";
import axios from "axios";
import { execSync } from "child_process";
import fetch from "node-fetch";
import { addExif } from "../lib/sticker.js";
import { Sticker } from "wa-sticker-formatter";

let cooldown = new Map();

let handler = async (a, { conn: r, args: e }) => {
    var t = a.sender;
    let o;

    if (1 <= e.length) {
        o = e.join(" ");
    } else {
        if (!a.quoted || !a.quoted.text) return r.reply(a.chat, "Input atau reply text!", a);
        o = a.quoted.text;
    }

    if (!o) return r.reply(a.chat, "Contoh penggunaan: !bratvideo hello world", a);
    if (250 < o.length) return r.reply(a.chat, "Max 250 karakter!", a);

    if (cooldown.has(t)) {
        e = cooldown.get(t);
        e = (Date.now() - e) / 1e3;
        if (e < 10) return a.reply(`[❗] Tunggu ${Math.ceil(10 - e)} detik sebelum menggunakan perintah ini lagi.`);
    }

    cooldown.set(t, Date.now());
    r.sendReact(a.chat, "🕒", a.key);

    var n = o.split(" ");
    var i = path.resolve("tmp");
    var s = (fs.existsSync(i) || fs.mkdirSync(i), []);

    try {
        for (let e = 0; e < n.length; e++) {
            var p = n.slice(0, e + 1).join(" ");
            var c = await axios.get("https://brat.caliphdev.com/api/brat?text=" + encodeURIComponent(p), { responseType: "arraybuffer" }).catch(e => e.response);
            var l = path.join(i, `frame${e}.mp4`);
            fs.writeFileSync(l, c.data);
            s.push(l);
        }

        var f = path.join(i, "filelist.txt");
        let t = "";
        for (let e = 0; e < s.length; e++) {
            t += `file '${s[e]}'
duration 0.7
`;
        }
        t += `file '${s[s.length - 1]}'
duration 2
`;
        fs.writeFileSync(f, t);

        var h = path.join(i, "output.mp4");
        var d = execSync(`ffmpeg -y -f concat -safe 0 -i ${f} -vf "fps=30" -c:v libx264 -preset ultrafast -pix_fmt yuv420p ` + h);
        var videoBuffer = fs.readFileSync(h);
        var m = await mp4ToWebp(videoBuffer, { pack: global.packname, author: global.author });

        r.sendFile(a.chat, m, "sticker.webp", o, a);
        s.forEach(e => { fs.existsSync(e) && fs.unlinkSync(e); });
        fs.existsSync(f) && fs.unlinkSync(f);
        fs.existsSync(h) && fs.unlinkSync(h);
    } catch (e) {
        r.reply(a.chat, `Terjadi kesalahan saat membuat stiker.\n- ${e.message}`, a);
    }
};

async function mp4ToWebp(buffer, options) {
    options = options || { pack: "‎", author: "‎", crop: false };
    const data = {
        file: "data:video/mp4;base64," + buffer.toString("base64"),
        processOptions: {
            crop: options.crop,
            startTime: "00:00:00.0",
            endTime: "00:00:07.0",
            loop: 0
        },
        stickerMetadata: { ...options }
    };

    const response = await fetch("https://sticker-api.openwa.dev/convertMp4BufferToWebpDataUrl", {
        method: "POST",
        headers: {
            Accept: "application/json, text/plain, */*",
            "Content-Type": "application/json;charset=utf-8"
        },
        body: JSON.stringify(data)
    });

    return Buffer.from((await response.text()).split(";base64,")[1], "base64");
}

handler.help = handler.command = ["bratvideo"];
handler.tags = ["tools"];
export default handler; dan tolong sempurnakan informasi errornya maaf terjadi kesalahan saat mengambil output
Assistant: