Advertisement
samiroexpikachu

Snippet

Aug 24th, 2024
226
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: "snippet",
  6.     version: "1.0",
  7.     author: "Samir ล’",
  8.     countDown: 5,
  9.     role: 0,
  10.     description: {
  11.       vi: "",
  12.       en: "Create an image."
  13.     },
  14.     category: "๐——๐—˜๐—ฉ๐—˜๐—Ÿ๐—ข๐—ฃ๐—˜๐—ฅ",
  15.     guide: {
  16.       vi: "{pn} <prompt> --t <title> --p <padding> --s <theme> --m <darkMode>",
  17.       en: "{pn} <prompt> --t <title> --p <padding> --s <theme> --m <darkMode>"
  18.     }
  19.   },
  20.  
  21.   onStart: async function ({ api, event, args, message }) {
  22.     let prompt = '';
  23.     let title = 'Default Title';
  24.     let padding = 64;
  25.     let theme = 'ice';
  26.     let darkMode = 'true';
  27.  
  28.    
  29.     args.forEach((arg, index) => {
  30.       if (arg === '--t' && args[index + 1]) {
  31.         title = args[index + 1];
  32.       } else if (arg === '--p' && args[index + 1]) {
  33.         padding = parseInt(args[index + 1], 10);
  34.       } else if (arg === '--s' && args[index + 1]) {
  35.         theme = args[index + 1];
  36.       } else if (arg === '--m' && args[index + 1]) {
  37.         darkMode = args[index + 1];
  38.       } else if (!arg.startsWith('--')) {
  39.         prompt += arg + ' ';
  40.       }
  41.     });
  42.  
  43.     prompt = prompt.trim();
  44.  
  45.     if (!prompt) {
  46.       return message.reply("Please provide a prompt.");
  47.     }
  48.  
  49.     message.reply("Initializing image, please wait...", async (err, info) => {
  50.       let id = info.messageID;
  51.       try {
  52.        
  53.         const domainPart1 = 'https://www.samirxpikachu';
  54.         const domainPart2 = '.run';
  55.         const domainPart3 = '.place';
  56.  
  57.        
  58.         const API = `${domainPart1}${domainPart2}${domainPart3}/senet?code=${encodeURIComponent(prompt)}&title=${encodeURIComponent(title)}&theme=${encodeURIComponent(theme)}&padding=${padding}&language=auto&darkMode=${darkMode}`;
  59.        
  60.         const imageStream = await global.utils.getStreamFromURL(API);
  61.         message.unsend(id);
  62.         message.reply({
  63.           body: `  `,
  64.           attachment: imageStream
  65.         }, async (err, info) => {
  66.         });
  67.       } catch (error) {
  68.         console.error(error);
  69.         api.sendMessage(`Error: ${error}`, event.threadID);
  70.       }
  71.     });
  72.   }
  73. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement