Created
December 12, 2025 13:06
-
-
Save Reyz2902/5ea7be15c3ce4dfd8e838e318443dddd to your computer and use it in GitHub Desktop.
Uploaded via Bot WhatsApp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ffmpeg = require('fluent-ffmpeg'); | |
| const axios = require('axios'); | |
| const { promises: fs } = require('fs'); | |
| const path = require('path'); | |
| let handler = async (m, { conn, text, usedPrefix, command }) => { | |
| if (!text) { | |
| throw `Please provide some text.\n\n*Example:*\n${usedPrefix + command} Hello World`; | |
| } | |
| let packname = global.packname || "MyBot Sticker"; | |
| let author = global.author || "User"; | |
| let tempInput = ''; | |
| let tempOutput = ''; | |
| try { | |
| await m.reply('⏳ Creating sticker...'); | |
| // API | |
| const apiUrl = `https://api-faa.my.id/faa/brathd?text=${encodeURIComponent(text)}`; | |
| const { data } = await axios.get(apiUrl, { responseType: 'arraybuffer' }); | |
| // Save temporary input | |
| tempInput = path.join(__dirname, `../../tmp/${Date.now()}_hdinput.jpg`); | |
| tempOutput = path.join(__dirname, `../../tmp/${Date.now()}_hdoutput.webp`); | |
| await fs.writeFile(tempInput, data); | |
| // FFmpeg conversion to WebP sticker | |
| await new Promise((resolve, reject) => { | |
| ffmpeg(tempInput) | |
| .addOutputOptions([ | |
| "-vcodec", "libwebp", | |
| "-vf", | |
| "scale=512:512:force_original_aspect_ratio=decrease," + | |
| "fps=15," + | |
| "pad=512:512:(ow-iw)/2:(oh-ih)/2:color=white", | |
| "-lossless", "1", | |
| "-preset", "default", | |
| "-loop", "0", | |
| "-an", | |
| "-vsync", "0" | |
| ]) | |
| .toFormat("webp") | |
| .on("end", resolve) | |
| .on("error", reject) | |
| .save(tempOutput); | |
| }); | |
| // Send sticker | |
| await conn.sendMessage(m.chat, { | |
| sticker: { url: tempOutput }, | |
| packname, | |
| author | |
| }, { quoted: m }); | |
| } catch (e) { | |
| console.error(e); | |
| m.reply("❌ Error creating sticker. API might be down or input invalid."); | |
| } finally { | |
| // Cleanup temp files | |
| if (tempInput) fs.unlink(tempInput).catch(() => {}); | |
| if (tempOutput) fs.unlink(tempOutput).catch(() => {}); | |
| } | |
| }; | |
| handler.command = ['brat']; | |
| handler.tags = ['maker']; | |
| handler.help = ['brat <text>']; | |
| handler.description = 'Creates a HD style text sticker using FFmpeg.'; | |
| handler.limit = true; | |
| module.exports = handler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment