tolong sempurnakan kode ini agar dia support emoji iPhone import fs…
- User
User: tolong sempurnakan kode ini agar dia support emoji iPhone 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,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(" "),i=path.resolve("tmp"),s=(fs.existsSync(i)||fs.mkdirSync(i),[]);try{for(let e=0;e<n.length;e++){var p=n.slice(0,e+1).join(" "),c=await axios.get("https://brat.caliphdev.com/api/brat?text="+encodeURIComponent(p),{responseType:"arraybuffer"}).catch(e=>e.response),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"),d=(execSync(ffmpeg -y -f concat -safe 0 -i ${f} -vf "fps=30" -c:v libx264 -preset ultrafast -pix_fmt yuv420p+h),fs.readFileSync(h)),m=await mp4ToWebp(d,{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.+e.message,a)}};async function mp4ToWebp(e,t){t?(t.pack||(t.pack=""),t.author||(t.author=""),t.crop||(t.crop=!1)):t={pack:"",author:"",crop:!1};e={file:"data:video/mp4;base64,"+e.toString("base64"),processOptions:{crop:t?.crop,startTime:"00:00:00.0",endTime:"00:00:07.0",loop:0},stickerMetadata:{...t}},t=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(e)});return Buffer.from((await t.text()).split(";base64,")[1],"base64")}handler.help=handler.command=["bratvideo"],handler.tags=["tools"];export default handler; coba gunakan ini module wa-sticker-formatter User: tolong sempurnakan kode ini agar dia support emoji iPhone 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,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 {e}.mp4file '{s[s.length-1]}' duration 2 ffmpeg -y -f concat -safe 0 -i ${f} -vf "fps=30" -c:v libx264 -preset ultrafast -pix_fmt yuv420p Terjadi kesalahan saat membuat stiker.
- Assistant