forked from AyGemuy/Taylor-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot-setpp.js
More file actions
30 lines (30 loc) · 1.03 KB
/
Copy pathbot-setpp.js
File metadata and controls
30 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { default as Jimp } from "jimp";
const handler = async (m, {
conn,
args
}) => {
try {
let q = m.quoted ? m.quoted : m,
mime = (q.msg || q).mimetype || "";
if (!/image/.test(mime)) throw new Error("Pesan tidak berisi gambar");
{
let img = await q?.download();
if (!img) throw new Error("Foto tidak ditemukan");
await conn.updateProfilePicture(conn.user.jid, img), await conn.reply(m.chat, "Sukses Mengganti Foto Profile Bot!", m);
}
} catch (e) {
console.error(e), await conn.reply(m.chat, "Terjadi kesalahan saat menjalankan perintah", m);
}
};
handler.help = ["botsetpp"], handler.command = /^(botsetpp)$/i, handler.owner = !0;
export default handler;
async function generateProfilePicture(media) {
const jimp = await Jimp.read(media),
min = jimp.getWidth(),
max = jimp.getHeight(),
cropped = jimp.crop(0, 0, min, max);
return {
img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG),
preview: await cropped.normalize().getBufferAsync(Jimp.MIME_JPEG)
};
}