Encrypto-27-AI-BOT / plugins /convert-sticker.js
Encrypto27
first 10
394ec3a
raw
history blame
4.21 kB
/*/*
$$$$$$\ $$\
$$ __$$\ $$ |
$$ / \__|$$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$$$$$\ $$$$$$\
\$$$$$$\ $$ | $$ |$$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\
\____$$\ $$ | $$ |$$ | $$ |$$ / $$ |$$ | \__|$$ / $$ |$$ / $$ |
$$\ $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |$$ | $$ |
\$$$$$$ |\$$$$$$ |$$$$$$$ |\$$$$$$$ |$$ | \$$$$$$ |\$$$$$$$ |
\______/ \______/ \_______/ \_______|\__| \______/ \_______|
Project Name : Encrypto-27 AI
Creator : Diego Allies ( Dudas )
Repo : https://github.com/diegoallies/Encrypto-27-AI
Support : wa.me/27679291800
*/
const config = require('../config');
const { Sticker, StickerTypes } = require('wa-sticker-formatter');
const { cmd } = require('../command');
const { getRandom } = require('../lib/functions');
var imgmsg = '';
if (config.LANG === 'SI') imgmsg = 'ඡායාරූපයකට mention දෙන්න!';
else imgmsg = 'ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴘʜᴏᴛᴏ ғᴏʀ sᴛɪᴄᴋᴇʀ!';
var descg = '';
if (config.LANG === 'SI') descg = 'එය ඔබගේ mention දුන් ඡායාරූපය ස්ටිකර් බවට පරිවර්තනය කරයි.';
else descg = 'ɪᴛ ᴄᴏɴᴠᴇʀᴛs ʏᴏᴜʀ ʀᴇᴘʟɪᴇᴅ ᴘʜᴏᴛᴏ ᴛᴏ sᴛɪᴄᴋᴇʀ.';
cmd({
pattern: 'sticker',
react: '🪄',
alias: ['s', 'stic'],
desc: descg,
category: 'convert',
use: '.sticker <Reply to image>',
filename: __filename
}, async (conn, mek, m, { from, reply, isCmd, command, args, q, isGroup, pushname }) => {
try {
const isQuotedImage = m.quoted && (m.quoted.type === 'imageMessage' || (m.quoted.type === 'viewOnceMessage' && m.quoted.msg.type === 'imageMessage'));
const isQuotedSticker = m.quoted && m.quoted.type === 'stickerMessage';
if ((m.type === 'imageMessage') || isQuotedImage) {
const nameJpg = getRandom('.jpg');
const imageBuffer = isQuotedImage ? await m.quoted.download() : await m.download();
await require('fs').promises.writeFile(nameJpg, imageBuffer);
let sticker = new Sticker(nameJpg, {
pack: pushname, // The pack name
author: '', // The author name
type: q.includes('--crop') || q.includes('-c') ? StickerTypes.CROPPED : StickerTypes.FULL,
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 75, // The quality of the output file
background: 'transparent', // The sticker background color (only for full stickers)
});
const buffer = await sticker.toBuffer();
return conn.sendMessage(from, { sticker: buffer }, { quoted: mek });
} else if (isQuotedSticker) {
const nameWebp = getRandom('.webp');
const stickerBuffer = await m.quoted.download();
await require('fs').promises.writeFile(nameWebp, stickerBuffer);
let sticker = new Sticker(nameWebp, {
pack: '❄ENCRYPTO-27 - AI❄️', // The pack name
author: '『 DUDAS』', // The author name
type: q.includes('--crop') || q.includes('-c') ? StickerTypes.CROPPED : StickerTypes.FULL,
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 75, // The quality of the output file
background: 'transparent', // The sticker background color (only for full stickers)
});
const buffer = await sticker.toBuffer();
return conn.sendMessage(from, { sticker: buffer }, { quoted: mek });
} else {
return await reply(imgmsg);
}
} catch (e) {
reply('Error !!');
console.error(e);
}
});