Facebook
From kshitiz, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 138
  1. const axios = require("axios");
  2. const fs = require("fs");
  3. const path = require("path");
  4.  
  5. module.exports = {
  6.   config: {
  7.     name: "anivfx",
  8.     aliases: ["animevfx", "vfxanime"],
  9.     author: "Vex_Kshitiz",
  10.     version: "1.0",
  11.     cooldowns: 10,
  12.     role: 0,
  13.     shortDescription: "",
  14.     longDescription: "get random vfx animations videos of animes",
  15.     category: "anime",
  16.     guide: "{p}anivfx",
  17.   },
  18.  
  19.   onStart: async function ({ api, event, args, message }) {
  20.     api.setMessageReaction("?", event.messageID, (err) => {}, true);
  21.  
  22.     try {
  23.       const response = await axios.get(`https://vfx-animation.onrender.com/kshitiz`, { responseType: "stream" });
  24.  
  25.       const tempVideoPath = path.join(__dirname, "cache", `vfx.mp4`);
  26.  
  27.       const writer = fs.createWriteStream(tempVideoPath);
  28.       response.data.pipe(writer);
  29.  
  30.       writer.on("finish", async () => {
  31.         const stream = fs.createReadStream(tempVideoPath);
  32.  
  33.         message.reply({
  34.           body: ``,
  35.           attachment: stream,
  36.         });
  37.  
  38.         api.setMessageReaction("?", event.messageID, (err) => {}, true);
  39.       });
  40.     } catch (error) {
  41.       console.error(error);
  42.       message.reply("Sorry, an error occurred.");
  43.     }
  44.   }
  45. };
  46.