Advertisement
samiroexpikachu

Alchemy

Oct 17th, 2024
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios');
  2.  
  3. module.exports = {
  4.   config: {
  5.     name: "alchemy",
  6.     version: "1.0",
  7.     author: "Samir ล’",
  8.     countDown: 5,
  9.     role: 0,
  10.     description: {
  11.       vi: "",
  12.       en: "Generate a response using the Alchemy API."
  13.     },
  14.     category: "๐——๐—˜๐—ฉ๐—˜๐—Ÿ๐—ข๐—ฃ๐—˜๐—ฅ",
  15.     guide: {
  16.       vi: "{pn} <text>",
  17.       en: "{pn} <text>"
  18.     }
  19.   },
  20.  
  21.   onStart: async function ({ api, event, args, message }) {
  22.     if (args.length === 0) {
  23.       return message.reply("Please provide some text.");
  24.     }
  25.  
  26.     const text = args.join(' ');
  27.  
  28.     const domainPart1 = 'https://www.samirxpikachu';
  29.     const domainPart2 = '.run';
  30.     const domainPart3 = '.place';
  31.  
  32.     const apiUrl = `${domainPart1}${domainPart2}${domainPart3}/alchemy?text=${encodeURIComponent(text)}`;
  33.  
  34.     message.reply("Processing your request, please wait...", async (err, info) => {
  35.       const id = info.messageID;
  36.       try {
  37.         const imageStream = await axios.get(apiUrl, { responseType: 'stream' });
  38.         message.unsend(id);
  39.         message.reply({
  40.           body: `Here is your image:`,
  41.           attachment: imageStream.data
  42.         });
  43.       } catch (error) {
  44.         console.error(error);
  45.         api.sendMessage(`Error: ${error.message}`, event.threadID);
  46.       }
  47.     });
  48.   }
  49. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement