Skip to content

Instantly share code, notes, and snippets.

@ONLym22
Created December 31, 2025 14:40
Show Gist options
  • Select an option

  • Save ONLym22/f3be133f6f8f23e91ab5f4731b347cf8 to your computer and use it in GitHub Desktop.

Select an option

Save ONLym22/f3be133f6f8f23e91ab5f4731b347cf8 to your computer and use it in GitHub Desktop.
Uploaded via ONLym Bot
// πŸ“‚ Source: JavaScript
case "removebg":
case "rb": {
const q = m.quoted ? m.quoted : m;
const mime = (q.msg || q).mimetype || "";
if (!/image/.test(mime)) {
return xreply(`Kirim atau balas *gambar* dengan perintah *${prefix + command}*`);
}
if (!global.onlym) {
return xreply("❌ API key belum dikonfigurasi. Selesaikan pengaturan di index.js terlebih dahulu.");
}
xreact();
try {
const media = await vellia.downloadAndSaveMediaMessage(q);
const catBoxUrl = await uploadCatBox(media);
if (fs.existsSync(media)) fs.unlinkSync(media);
if (!catBoxUrl) {
return xreply("❌ Gagal mengunggah gambar ke server penyimpanan (Catbox).");
}
const apiUrl = `https://onlym.my.id/tools/removebg?url=${catBoxUrl}&apikey=${global.onlym}`;
const apiRes = await axios.get(apiUrl, {
responseType: "arraybuffer",
timeout: 60000
});
if (!apiRes.data || apiRes.data.byteLength < 100) {
return xreply("❌ Gagal memproses gambar. API mengembalikan hasil kosong.");
}
await vellia.sendMessage(m.chat, {
image: Buffer.from(apiRes.data),
caption: `✨ *Background Removed*\n\n` +
`πŸš€ *Engine:* ONLym Tools\n` +
`πŸ”— *Api:* https://onlym.my.id/\n\n` +
`${global.wm}`
}, { quoted: qkontak });
xreact("βœ…");
} catch (err) {
console.error("[REMOVEBG ERROR]", err.message);
const errMsg = err.response?.status === 403
? "⚠️ API Key tidak valid atau limit habis."
: "⚠️ Gagal menghapus background. Pastikan subjek gambar jelas.";
xreply(errMsg);
xreact("❌");
}
}
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment