Shisui_Daniel

Untitled

May 7th, 2025
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 25.02 KB | None | 0 0
  1. const axios = require("axios")
  2.  
  3. const serverURL = "https://commandstore-api.onrender.com"
  4. const ADMIN_UID = ["61563822463333", "100090405019929"]
  5.  
  6. function formatNumber(number) {
  7.   const suffixes = [
  8.     "", " thousand", " million", " billion", " billiard", " trillion", " trilliard",
  9.     " quadrillion", " quadrilliard", " quintillion", " quintilliard", " sextillion", " sextilliard",
  10.     " septillion", " septilliard", " octillion", " octilliard", " nonillion", " nonilliard",
  11.     " decillion", " decilliard", " undecillion", " undecilliard", " duodecillion", " duodecilliard",
  12.     " tredecillion", " tredecilliard", " quattuordecillion", " quattuordecilliard", " quindecillion",
  13.     " quindecilliard", " sexdecillion", " sexdecilliard", " septendecillion", " septendecilliard",
  14.     " octodecillion", " octodecilliard", " novemdecillion", " novemdecilliard", " vigintillion",
  15.     " vigintilliard", " unvigintillion", " unvigintilliard", " duovigintillion", " duovigintilliard",
  16.     " trevigintillion", " trevigintilliard", " quattuorvigintillion", " quattuorvigintilliard",
  17.     " quinvigintillion", " quinvigintilliard", " sexvigintillion", " sexvigintilliard",
  18.     " septenvigintillion", " septenvigintilliard", " octovigintillion", " octovigintilliard",
  19.     " novemvigintillion", " novemvigintilliard", " trigintillion", " trigintilliard",
  20.     " untrigintillion", " untrigintilliard", " duotrigintillion", " duotrigintilliard",
  21.     " tretrigintillion", " tretrigintilliard", " quattuortrigintillion", " quattuortrigintilliard",
  22.     " quintrigintillion", " quintrigintilliard", " sextrigintillion", " sextrigintilliard",
  23.     " septentrigintillion", " septentrigintilliard", " octotrigintillion", " octotrigintilliard",
  24.     " novemtrigintillion", " novemtrigintilliard", " quadragintillion", " quadragintilliard",
  25.     " unquadragintillion", " unquadragintilliard", " duoquadragintillion", " duoquadragintilliard",
  26.     " trequadragintillion", " trequadragintilliard", " quattuorquadragintillion", " quattuorquadragintilliard",
  27.     " quinquadragintillion", " quinquadragintilliard", " sexquadragintillion", " sexquadragintilliard",
  28.     " septenquadragintillion", " septenquadragintilliard", " octoquadragintillion", " octoquadragintilliard",
  29.     " novemquadragintillion", " novemquadragintilliard", " quinquagintillion", " quinquagintilliard"
  30.   ]
  31.   if (!Number.isFinite(number) || number === null || number === undefined) return "Price not defined"
  32.   if (number < 1000) return number.toString()
  33.   let exponent = Math.floor(Math.log10(number) / 3)
  34.   let shortNumber = number / Math.pow(1000, exponent)
  35.   return `${shortNumber.toFixed(2)}${suffixes[exponent]}`
  36. }
  37.  
  38. module.exports = {
  39.   config: {
  40.     name: "store",
  41.     aliases: ["commandstore"],
  42.     version: "4.2",
  43.     role: 0,
  44.     shortDescription: {
  45.       en: "Access the premium command store"
  46.     },
  47.     longDescription: {
  48.       en: "Allows you to search and buy premium commands available in the CommandStore.\n- Use 'store page <number>' to view commands by page.\n- Use 'store search <name>' to search for a specific command.\n- Use 'store search category <category>' to view commands in a category."
  49.     },
  50.     guide: {
  51.       en: "{p}page <number>\n{p}search <command name>\n{p}search category <category>"
  52.     },
  53.     author: "ćƒŸā˜…š’šŽššˆš‚āœ„š„š—š„ 3.0ā˜…å½” || L'Uchiha Perdu",
  54.     category: "economy"
  55.   },
  56.  
  57.   onStart: async ({ api, event, args, message, usersData }) => {
  58.     try {
  59.       if (args[0]?.toLowerCase() === "page") {
  60.         const page = parseInt(args[1]) || 1
  61.         const perPage = 15
  62.         const response = await axios.get(`${serverURL}/api/commands`)
  63.         const commands = response.data
  64.         if (!commands.length) {
  65.           return api.sendMessage(
  66.             "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø No commands available at the moment.\nCome back later! šŸ•’\n━━━━━━━━━━━━━━━",
  67.             event.threadID,
  68.             event.messageID
  69.           )
  70.         }
  71.         const totalPages = Math.ceil(commands.length / perPage)
  72.         if (page < 1 || page > totalPages) {
  73.           return api.sendMessage(
  74.             `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Please specify a valid page number.\nAvailable pages: 1 to ${totalPages}\nāž¤ Usage: store page <number>\n━━━━━━━━━━━━━━━`,
  75.             event.threadID,
  76.             event.messageID
  77.           )
  78.         }
  79.         const start = (page - 1) * perPage
  80.         const end = start + perPage
  81.         const paginatedCommands = commands.slice(start, end)
  82.         const commandList = paginatedCommands.map((cmd, index) =>
  83.           `${start + index + 1}- ${cmd.itemName}`
  84.         ).join("\n")
  85.         return api.sendMessage(
  86.           `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nšŸ“œ List of commands (Page ${page}/${totalPages}):\n${commandList}\n━━━━━━━━━━━━━━━\nReply with the number of the command to buy (e.g., "1" for the first command).`,
  87.           event.threadID,
  88.           (err, info) => {
  89.             if (err) return api.sendMessage(
  90.               "āŒ An error occurred while sending the message.",
  91.               event.threadID, event.messageID
  92.             )
  93.             global.GoatBot.onReply.set(info.messageID, {
  94.               commandName: "store",
  95.               type: "select",
  96.               messageID: info.messageID,
  97.               commands: paginatedCommands,
  98.               userID: event.senderID,
  99.               threadID: event.threadID,
  100.               expiresAt: Date.now() + 300000
  101.             })
  102.           },
  103.           event.messageID
  104.         )
  105.       }
  106.  
  107.       if (args[0]?.toLowerCase() === "search") {
  108.         if (args[1]?.toLowerCase() === "category") {
  109.           if (!args[2]) {
  110.             return api.sendMessage(
  111.               "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Please specify a category!\nāž¤ Usage: store search category <category>\n━━━━━━━━━━━━━━━",
  112.               event.threadID,
  113.               event.messageID
  114.             )
  115.           }
  116.           const category = args.slice(2).join(" ")
  117.           const response = await axios.get(`${serverURL}/api/commands`)
  118.           const commands = response.data
  119.           const filteredCommands = commands.filter(cmd => cmd.category?.toLowerCase() === category.toLowerCase())
  120.           if (!filteredCommands.length) {
  121.             return api.sendMessage(
  122.               "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø No commands found in the specified category!\nTry another category or check the spelling. šŸ”\nāž¤ Usage: store search category <category>\n━━━━━━━━━━━━━━━",
  123.               event.threadID,
  124.               event.messageID
  125.             )
  126.           }
  127.           const commandList = filteredCommands.map((cmd, index) =>
  128.             `${index + 1}- ${cmd.itemName}`
  129.           ).join("\n")
  130.           return api.sendMessage(
  131.             `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nšŸ“œ Commands in category "${category}":\n${commandList}\n━━━━━━━━━━━━━━━\nReply with the number of the command to buy (e.g., "1" for the first command).`,
  132.             event.threadID,
  133.             (err, info) => {
  134.               if (err) return api.sendMessage(
  135.                 "āŒ An error occurred while sending the message.",
  136.                 event.threadID, event.messageID
  137.               )
  138.               global.GoatBot.onReply.set(info.messageID, {
  139.                 commandName: "store",
  140.                 type: "select",
  141.                 messageID: info.messageID,
  142.                 commands: filteredCommands,
  143.                 userID: event.senderID,
  144.                 threadID: event.threadID,
  145.                 expiresAt: Date.now() + 300000
  146.               })
  147.             },
  148.             event.messageID
  149.           )
  150.         } else {
  151.           if (!args[1]) {
  152.             return api.sendMessage(
  153.               "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Please specify the name of the command to search for!\nāž¤ Usage: store search <command name>\n━━━━━━━━━━━━━━━",
  154.               event.threadID,
  155.               event.messageID
  156.             )
  157.           }
  158.           const cmdName = args.slice(1).join(" ")
  159.           const response = await axios.get(`${serverURL}/api/commands/${cmdName}`)
  160.           const item = response.data
  161.           if (!Object.keys(item).length) {
  162.             return api.sendMessage(
  163.               "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Command not found!\nThis command might be too common and has no value here.\nThis store is for elite commands only! šŸ’Ž\nāž¤ Try using cmdstore for basic commands.\n━━━━━━━━━━━━━━━",
  164.               event.threadID,
  165.               event.messageID
  166.             )
  167.           }
  168.           if (!Number.isFinite(item.price)) {
  169.             return api.sendMessage(
  170.               `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø The command "${cmdName}" has an invalid price!\nContact anAadministrator to fix this.\n━━━━━━━━━━━━━━━`,
  171.               event.threadID,
  172.               event.messageID
  173.             )
  174.           }
  175.           const formattedPrice = formatNumber(item.price)
  176.           return api.sendMessage(
  177.             `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāœ… Command "${item.itemName}" found!\nRank: ${item.rank}\nThe command costs ${formattedPrice} $.\nWould you like to pay to get it? šŸ›ļø\nReply to this message with "yes" or "no".\n━━━━━━━━━━━━━━━`,
  178.             event.threadID,
  179.             (err, info) => {
  180.               if (err) return api.sendMessage(
  181.                 "āŒ An error occurred while sending the message.",
  182.                 event.threadID, event.messageID
  183.               )
  184.               global.GoatBot.onReply.set(info.messageID, {
  185.                 commandName: "store",
  186.                 type: "confirm",
  187.                 messageID: info.messageID,
  188.                 item: item,
  189.                 userID: event.senderID,
  190.                 threadID: event.threadID,
  191.                 expiresAt: Date.now() + 300000
  192.               })
  193.             },
  194.             event.messageID
  195.           )
  196.         }
  197.       }
  198.  
  199.       if (args[0]?.toLowerCase() === "put" && ADMIN_UID.includes(event.senderID)) {
  200.         return api.sendMessage(
  201.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nšŸ“ Adding a new command.\nStep 1/6: Enter the command name (e.g., \"Join\"):\nReply to this message with the name, or type \"cancel\" to stop.\n━━━━━━━━━━━━━━━",
  202.           event.threadID,
  203.           (err, info) => {
  204.             if (err) return api.sendMessage(
  205.               "āŒ An error occurred while sending the message.",
  206.               event.threadID, event.messageID
  207.             )
  208.             global.GoatBot.onReply.set(info.messageID, {
  209.               commandName: "store",
  210.               type: "put_form",
  211.               step: 1,
  212.               messageID: info.messageID,
  213.               userID: event.senderID,
  214.               threadID: event.threadID,
  215.               expiresAt: Date.now() + 300000,
  216.               formData: {}
  217.             })
  218.           },
  219.           event.messageID
  220.         )
  221.       }
  222.  
  223.       return api.sendMessage(
  224.         "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Invalid command!\nāž¤ Usage: store page <number>\nāž¤ Usage: store search <command name>\nāž¤ Usage: store search category <category>\n━━━━━━━━━━━━━━━",
  225.         event.threadID,
  226.         event.messageID
  227.       )
  228.     } catch (error) {
  229.       return api.sendMessage(
  230.         "āŒ An unexpected error occurred: " + error.message,
  231.         event.threadID,
  232.         event.messageID
  233.       )
  234.     }
  235.   },
  236.  
  237.   onReply: async ({ api, event, message, Reply, usersData }) => {
  238.     const { commandName, type, step, messageID, userID, threadID, expiresAt, formData, item, commands } = Reply
  239.  
  240.     if (event.senderID !== userID || event.threadID !== threadID) return
  241.  
  242.     if (Date.now() > expiresAt) {
  243.       global.GoatBot.onReply.delete(messageID)
  244.       return api.sendMessage(
  245.         "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nā³ Sorry, the time to respond to this request has expired (5 minutes).\nWould you like to start over?\n━━━━━━━━━━━━━━━",
  246.         event.threadID,
  247.         event.messageID
  248.       )
  249.     }
  250.  
  251.     if (commandName === "store" && type === "put_form") {
  252.       const response = event.body.trim()
  253.       const cancelCheck = response.toLowerCase()
  254.  
  255.       if (cancelCheck === "cancel") {
  256.         global.GoatBot.onReply.delete(messageID)
  257.         return api.sendMessage(
  258.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāŒ Command addition canceled.\n━━━━━━━━━━━━━━━",
  259.           event.threadID,
  260.           event.messageID
  261.         )
  262.       }
  263.  
  264.       if (step === 1) {
  265.         if (!response) {
  266.           return api.sendMessage(
  267.             "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāš ļø The command name cannot be empty!\nStep 1/6: Enter the command name (e.g., \"Join\"):\n━━━━━━━━━━━━━━━",
  268.             event.threadID,
  269.             event.messageID
  270.           )
  271.         }
  272.         formData.itemName = response
  273.         return api.sendMessage(
  274.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nšŸ“ Step 2/6: Enter the author of the command (e.g., \"Vex_Kshitiz\"):\nReply to this message with the author, or type \"cancel\" to stop.\n━━━━━━━━━━━━━━━",
  275.           event.threadID,
  276.           (err, info) => {
  277.             if (err) return api.sendMessage(
  278.               "āŒ An error occurred while sending the message.",
  279.               event.threadID, event.messageID
  280.             )
  281.             global.GoatBot.onReply.set(info.messageID, {
  282.               commandName: "store",
  283.               type: "put_form",
  284.               step: 2,
  285.               messageID: info.messageID,
  286.               userID: event.senderID,
  287.               threadID: event.threadID,
  288.               expiresAt: Date.now() + 300000,
  289.               formData
  290.             })
  291.           },
  292.           event.messageID
  293.         )
  294.       }
  295.  
  296.       if (step === 2) {
  297.         if (!response) {
  298.           return api.sendMessage(
  299.             "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāš ļø The author of the command cannot be empty!\nStep 2/6: Enter the author of the command (e.g., \"Vex_Kshitiz\"):\n━━━━━━━━━━━━━━━",
  300.             event.threadID,
  301.             event.messageID
  302.           )
  303.         }
  304.         formData.authorName = response
  305.         return api.sendMessage(
  306.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nšŸ“ Step 3/6: Enter the rank of the command (e.g., \"C\"):\nReply to this message with the rank, or type \"cancel\" to stop.\n━━━━━━━━━━━━━━━",
  307.           event.threadID,
  308.           (err, info) => {
  309.             if (err) return api.sendMessage(
  310.               "āŒ An error occurred while sending the message.",
  311.               event.threadID, event.messageID
  312.             )
  313.             global.GoatBot.onReply.set(info.messageID, {
  314.               commandName: "store",
  315.               type: "put_form",
  316.               step: 3,
  317.               messageID: info.messageID,
  318.               userID: event.senderID,
  319.               threadID: event.threadID,
  320.               expiresAt: Date.now() + 300000,
  321.               formData
  322.             })
  323.           },
  324.           event.messageID
  325.         )
  326.       }
  327.  
  328.       if (step === 3) {
  329.         if (!response) {
  330.           return api.sendMessage(
  331.             "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāš ļø The rank of the command cannot be empty!\nStep 3/6: Enter the rank of the command (e.g., \"C\"):\n━━━━━━━━━━━━━━━",
  332.             event.threadID,
  333.             event.messageID
  334.           )
  335.         }
  336.         formData.rank = response
  337.         return api.sendMessage(
  338.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nšŸ“ Step 4/6: Enter the price of the command (e.g., \"10000000000\"):\nReply to this message with the price, or type \"cancel\" to stop.\n━━━━━━━━━━━━━━━",
  339.           event.threadID,
  340.           (err, info) => {
  341.             if (err) return api.sendMessage(
  342.               "āŒ An error occurred while sending the message.",
  343.               event.threadID, event.messageID
  344.             )
  345.             global.GoatBot.onReply.set(info.messageID, {
  346.               commandName: "store",
  347.               type: "put_form",
  348.               step: 4,
  349.               messageID: info.messageID,
  350.               userID: event.senderID,
  351.               threadID: event.threadID,
  352.               expiresAt: Date.now() + 300000,
  353.               formData
  354.             })
  355.           },
  356.           event.messageID
  357.         )
  358.       }
  359.  
  360.       if (step === 4) {
  361.         const price = Number(response)
  362.         if (isNaN(price) || price <= 0) {
  363.           return api.sendMessage(
  364.             `šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāš ļø The price "${response}" must be a valid number greater than 0!\nStep 4/6: Enter the price of the command (e.g., "10000000000"):\n━━━━━━━━━━━━━━━`,
  365.             event.threadID,
  366.             event.messageID
  367.           )
  368.         }
  369.         formData.price = price
  370.         return api.sendMessage(
  371.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nšŸ“ Step 5/6: Enter the Pastebin link of the command (e.g., \"https://pastebin.com/raw/uWjDB6Zx\"):\nReply to this message with the link, or type \"cancel\" to stop.\n━━━━━━━━━━━━━━━",
  372.           event.threadID,
  373.           (err, info) => {
  374.             if (err) return api.sendMessage(
  375.               "āŒ An error occurred while sending the message.",
  376.               event.threadID, event.messageID
  377.             )
  378.             global.GoatBot.onReply.set(info.messageID, {
  379.               commandName: "store",
  380.               type: "put_form",
  381.               step: 5,
  382.               messageID: info.messageID,
  383.               userID: event.senderID,
  384.               threadID: event.threadID,
  385.               expiresAt: Date.now() + 300000,
  386.               formData
  387.             })
  388.           },
  389.           event.messageID
  390.         )
  391.       }
  392.  
  393.       if (step === 5) {
  394.         if (!response || !response.startsWith("https://pastebin.com/")) {
  395.           return api.sendMessage(
  396.             "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāš ļø The link must be a valid Pastebin link (e.g., \"https://pastebin.com/raw/uWjDB6Zx\")!\nStep 5/6: Enter the Pastebin link of the command:\n━━━━━━━━━━━━━━━",
  397.             event.threadID,
  398.             event.messageID
  399.           )
  400.         }
  401.         formData.pastebinLink = response
  402.         return api.sendMessage(
  403.           "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nšŸ“ Step 6/6: Enter the category of the command (e.g., \"Admin\"):\nReply to this message with the category, or type \"cancel\" to stop.\n━━━━━━━━━━━━━━━",
  404.           event.threadID,
  405.           (err, info) => {
  406.             if (err) return api.sendMessage(
  407.               "āŒ An error occurred while sending the message.",
  408.               event.threadID, event.messageID
  409.             )
  410.             global.GoatBot.onReply.set(info.messageID, {
  411.               commandName: "store",
  412.               type: "put_form",
  413.               step: 6,
  414.               messageID: info.messageID,
  415.               userID: event.senderID,
  416.               threadID: event.threadID,
  417.               expiresAt: Date.now() + 300000,
  418.               formData
  419.             })
  420.           },
  421.           event.messageID
  422.         )
  423.       }
  424.  
  425.       if (step === 6) {
  426.         if (!response) {
  427.           return api.sendMessage(
  428.             "šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāš ļø The category of the command cannot be empty!\nStep 6/6: Enter the category of the command (e.g., \"Admin\"):\n━━━━━━━━━━━━━━━",
  429.             event.threadID,
  430.             event.messageID
  431.           )
  432.         }
  433.         formData.category = response
  434.         const newCommand = {
  435.           itemName: formData.itemName,
  436.           authorName: formData.authorName,
  437.           rank: formData.rank,
  438.           price: formData.price,
  439.           pastebinLink: formData.pastebinLink,
  440.           category: formData.category
  441.         }
  442.         console.log("Data sent to the API:", newCommand)
  443.         await axios.put(`${serverURL}/api/commands/${formData.itemName}`, newCommand)
  444.         global.GoatBot.onReply.delete(messageID)
  445.         return api.sendMessage(
  446.           `šŸ› ļø 怖 StoreAdmin 怗 šŸ› ļø\n━━━━━━━━━━━━━━━\nāœ… Command "${formData.itemName}" added/updated successfully!\n━━━━━━━━━━━━━━━`,
  447.           event.threadID,
  448.           event.messageID
  449.         )
  450.       }
  451.     }
  452.  
  453.    if (commandName === "store" && type === "confirm") {
  454.       const reply = event.body.toLowerCase().trim()
  455.       if (reply === "yes") {
  456.         try {
  457.           const userMoney = await usersData.get(userID, "money")
  458.           if (!item || !Number.isFinite(item.price)) {
  459.             global.GoatBot.onReply.delete(messageID)
  460.             return api.sendMessage(
  461.               `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Error: The command data is invalid!\nContact an administrator.\n━━━━━━━━━━━━━━━`,
  462.               event.threadID,
  463.               event.messageID
  464.             )
  465.           }
  466.           if (userMoney < item.price) {
  467.             const formattedMissing = formatNumber(item.price - userMoney)
  468.             global.GoatBot.onReply.delete(messageID)
  469.             return api.sendMessage(
  470.               `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Insufficient funds!\nYou need ${formattedMissing} $ more to buy "${item.itemName}".\nIncrease your balance and try again! šŸ’°\n━━━━━━━━━━━━━━━`,
  471.               event.threadID,
  472.               event.messageID
  473.             )
  474.           }
  475.           await usersData.set(userID, { money: userMoney - item.price })
  476.           const requiredFields = ["itemName", "authorName", "category", "rank", "pastebinLink", "price"]
  477.           for (const field of requiredFields) {
  478.             if (!item[field]) {
  479.               global.GoatBot.onReply.delete(messageID)
  480.               return api.sendMessage(
  481.                 `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Error: The command "${item.itemName || "unknown"}" is missing data (${field})!\nContact an administrator.\n━━━━━━━━━━━━━━━`,
  482.                 event.threadID,
  483.                 event.messageID
  484.               )
  485.             }
  486.           }
  487.           global.GoatBot.onReply.delete(messageID)
  488.           return api.sendMessage(
  489.             `šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nšŸŽ‰ Purchase successful!\nāž¤ Name: ${item.itemName}\nāž¤ Author: ${item.authorName}\nāž¤ Category: ${item.category}\nāž¤ Rank: ${item.rank}\nāž¤ Link: ${item.pastebinLink}\nāž¤ Price: ${formatNumber(item.price)} $\nThank you for your trust! šŸ›ļø\n━━━━━━━━━━━━━━━`,
  490.             event.threadID,
  491.             event.messageID
  492.           )
  493.         } catch (error) {
  494.           return api.sendMessage(
  495.             "āŒ An error occurred during the purchase: " + error.message,
  496.             event.threadID,
  497.             event.messageID
  498.           )
  499.         }
  500.       } else if (reply === "no") {
  501.         global.GoatBot.onReply.delete(messageID)
  502.         return api.sendMessage(
  503.           "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nToo bad... Maybe next time? šŸ›ļø\n━━━━━━━━━━━━━━━",
  504.           event.threadID,
  505.           event.messageID
  506.         )
  507.       } else {
  508.         return api.sendMessage(
  509.           "šŸ›’ 怖 CommandStore 怗 šŸ›’\n━━━━━━━━━━━━━━━\nāš ļø Please reply with only \"yes\" or \"no\".\n━━━━━━━━━━━━━━━",
  510.           event.threadID,
  511.           event.messageID
  512.         )
  513.       }
  514.     }
  515.   }
  516. }
Add Comment
Please, Sign In to add comment