goat
command
emojigif
Get emoji image
0
views
0
likes
0
installs
raw source
const axios = require("axios");
const fs = require("fs-extra");
const path = require("path");
module.exports = {
config: {
name: "emojigif",
version: "1.0",
author: "Xalman",
countDown: 5,
role: 0,
shortDescription: {
en: "Get emoji image"
},
category: "FUN & SOCIAL",
guide: {
en: "{pn} ๐"
}
},
onStart: async function ({ message, args }) {
try {
const emoji = args.join(" ");
if (!emoji)
return message.reply("โ | Please provide an emoji");
const apiUrl = `https://xalman-apis.vercel.app/api/emojigif?emoji=${encodeURIComponent(emoji)}`;
const res = await axios.get(apiUrl);
const imageUrl = res.data?.data?.image;
if (!imageUrl)
return message.reply("โ | No image found");
const filePath = path.join(
__dirname,
"cache",
`emoji_${Date.now()}.webp`
);
const img = await axios({
url: imageUrl,
method: "GET",
responseType: "stream"
});
const writer = fs.createWriteStream(filePath);
img.data.pipe(writer);
writer.on("finish", async () => {
await message.reply({
body: `Emoji: ${emoji}`,
attachment: fs.createReadStream(filePath)
});
fs.unlinkSync(filePath);
});
writer.on("error", () => {
message.reply("โ | Failed to download image");
});
} catch (err) {
console.error(err);
message.reply("โ | API Error");
}
}
};