Skip to content

Instantly share code, notes, and snippets.

@mifyow
Created October 25, 2025 04:51
Show Gist options
  • Select an option

  • Save mifyow/897893c6f67d195518da7d846109d9f1 to your computer and use it in GitHub Desktop.

Select an option

Save mifyow/897893c6f67d195518da7d846109d9f1 to your computer and use it in GitHub Desktop.
Uploaded via Mifinfinity-
import fs from "fs"
import axios from "axios"
import FormData from "form-data"
import { fileTypeFromBuffer } from "file-type"
import util from "util"
export default {
name: "tourllunara",
category: "tools",
command: ["tourl", "upload", "lunara"],
run: async (conn, m) => {
try {
const q = m.quoted ? m.quoted : m
const mime = (q.msg || q).mimetype || q.mimetype || ""
if (!mime) return m.reply("❌ *Balas media yang ingin diupload ke Lunara!*")
const loading = await m.reply("☁️ *Mengunggah ke Lunara...*")
const buffer = await q.download?.()
if (!buffer) return m.reply("⚠️ *Gagal mengunduh media!*")
const detected = await fileTypeFromBuffer(buffer)
const ext = detected?.ext || mime.split("/")[1] || "bin"
const fileName = `upload_${Date.now()}.${ext}`
fs.writeFileSync(fileName, buffer)
const form = new FormData()
form.append("file", fs.createReadStream(fileName))
form.append("expire_value", "24")
form.append("expire_unit", "hours")
const res = await axios.post("https://lunara.drizznesiasite.biz.id/upload", form, {
headers: form.getHeaders(),
maxBodyLength: Infinity,
maxContentLength: Infinity
})
const resultUrl = res?.data?.file_url
if (!resultUrl) {
return conn.sendMessage(m.chat, {
edit: loading.key,
text: "❌ *Gagal mendapatkan URL dari Lunara!*"
})
}
await conn.sendMessage(m.chat, {
edit: loading.key,
text: `✅ *Berhasil upload ke Lunara!*\n\n📄 *Nama File:* ${fileName}\n🔗 *URL:* ${resultUrl}`
})
try { fs.unlinkSync(fileName) } catch {}
} catch (err) {
console.error("❌ Upload error:", err)
await m.reply(`⚠️ *Gagal upload ke Lunara!*\n${util.format(err)}`)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment