zein69

momo lama

Jan 24th, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const {
  2.     Client,
  3.     WebhookClient,
  4.     MessageEmbed,
  5.     Role,
  6. } = require("discord.js-selfbot-v13");
  7. const { createWorker } = require("tesseract.js");
  8. const { getColorFromURL } = require("color-thief-node");
  9. const { OtakudesuInstance } = require("otakudesu-scraper");
  10. const rgbToHex = require("rgb-hex");
  11. const mongoose = require("mongoose");
  12. const jsonFruit = require("./fruits.json");
  13. const cron = require("node-cron");
  14. const fs = require("fs");
  15. const PrettyError = require("pretty-error");
  16. require("dotenv").config();
  17.  
  18. const pe = new PrettyError();
  19. const client = new Client({
  20.     // syncStatus: false,
  21.     checkUpdate: false,
  22. });
  23.  
  24. const webhookClient = new WebhookClient({ url: process.env.WEBHOOK });
  25.  
  26. let arrFruitsNama = [];
  27.  
  28. (async () => {
  29.     for (let i = 0; i < jsonFruit.length; i++) {
  30.         const obj = jsonFruit[i];
  31.         arrFruitsNama.push(obj.nama);
  32.     }
  33. })();
  34.  
  35. client.on("ready", async () => {
  36.     // require('./server');
  37.     console.log(`${client.user.username} is ready!`);
  38.  
  39.      try {
  40.         await mongoose.connect(process.env.MONGO);
  41.         console.log("Mongodb Success Connected To Database");
  42.      } catch (err) {
  43.         //console.error(`Error ` + err.message);
  44.         // return `Error ` + err;
  45.      }
  46.     client.user.setSamsungActivity("com.YoStarEN.AzurLane", "START");
  47.     // const guild = client.guilds.cache;
  48.     // const guild1 = guild.get("1021954822116749332");
  49.     // const invite = guild1.invites.create("1114380738528301137", {
  50.     //     maxAge: 0,
  51.     //     maxUses: 100000,
  52.     // });
  53.     return;
  54. });
  55.  
  56. let send = false;
  57. let sendTry = 0;
  58. let time = -769171800;
  59. let cekIni = 0;
  60.  
  61. client.on("messageCreate", async (msg) => {
  62.     const guild = client.guilds.cache;
  63.     // if (msg.author.id === client.user.id) { return }
  64.     if (msg.author.id === "819362961239703562" && msg.content === "!status") {
  65.         let totalSeconds = client.uptime / 1000;
  66.         let days = Math.floor(totalSeconds / 86400);
  67.         totalSeconds %= 86400;
  68.         let hours = Math.floor(totalSeconds / 3600);
  69.         totalSeconds %= 3600;
  70.         let minutes = Math.floor(totalSeconds / 60);
  71.         let seconds = Math.floor(totalSeconds % 60);
  72.         let time = Math.floor(client.readyTimestamp / 1000);
  73.         msg.reply(
  74.             "im good :)\nPing: " +
  75.                 Math.round(client.ws.ping) +
  76.                 "ms\nUptime : " +
  77.                 days +
  78.                 "d " +
  79.                 hours +
  80.                 "h " +
  81.                 minutes +
  82.                 "m " +
  83.                 seconds +
  84.                 "s\n<t:" +
  85.                 time +
  86.                 ":F> | <t:" +
  87.                 time +
  88.                 ":R>"
  89.         );
  90.     }
  91.     if (msg.channelId === "1037758983315931136") {
  92.         try {
  93.             let before = 0;
  94.             let after = 0;
  95.             let timeExe = 0;
  96.             let men = [];
  97.             before = +new Date();
  98.             before /= 1000;
  99.             const embedRaw = msg.embeds[0];
  100.             let cek = embedRaw.fields[0].name;
  101.             cek = cek.toLowerCase();
  102.             let typeStock = "Unknwon";
  103.             //depreacte
  104.             // const arrCek = ["Mirage", "Normal"];
  105.             // for (let i = 0; i < arrCek.length; i++) {
  106.             //     const obj = arrCek[i];
  107.             //     if (!cek.includes(obj) && i === 1) {
  108.             //         return;
  109.             //     } else if (cek.includes(obj)) {
  110.             //         typeStock = obj;
  111.             //         break;
  112.             //     } else {
  113.             //         continue;
  114.             //     }
  115.             // }
  116.             if (!cek.includes("normal")) {
  117.                 console.log(1);
  118.                 return;
  119.             }
  120.             typeStock = "Normal";
  121.             //deprecated
  122.             // typeStock = cek;
  123.             // if (typeStock === "Unknwon" || typeStock === "Mirage") {
  124.             //     return;
  125.             // }
  126.  
  127.             //cek kalok waktu nya gak pas
  128.             if (!send) {
  129.                 // console.log(`bukan saatnya`);
  130.                 return;
  131.             }
  132.  
  133.             const guild1 = guild.get("1036669101122277387"); //guild validation
  134.             const channelok = guild1.channels.cache.get("1187729967484772413"); //ch validation
  135.             let msgraw = await channelok.messages.fetch({ limit: 1 });
  136.             msgraw = msgraw.entries().next().value[1];
  137.             let msgfix = msgraw.content;
  138.             let split1 = msgfix.split("\n");
  139.             //cek kalok di validation nya rusak
  140.             if (split1[0] != "stockbuah") {
  141.                 const guild1 = guild.get("1021954822116749332"); //guild shin
  142.                 const channel1 = guild1.channels.cache.get(
  143.                     "1189178957371818035"
  144.                 ); //ch shin
  145.                 channel1.send(
  146.                     `<@819362961239703562>\n[ERR] msg validation salah di <#1187729967484772413>\n${msgraw.url}\n`
  147.                 );
  148.                 console.log(`salah msg`);
  149.                 return;
  150.             }
  151.             let split2 = split1[1].split(",");
  152.             let arrCheck = [];
  153.             let rawFruit = embedRaw.fields[0].value.replaceAll("\n", "");
  154.             let arrayFruit = [];
  155.             for (let i = 0; i < jsonFruit.length; i++) {
  156.                 const obj = jsonFruit[i];
  157.                 if (rawFruit.includes(obj.fruit)) {
  158.                     arrayFruit.push(
  159.                         `- ${obj.emoji} ${obj.roleId} <a:arrow:1190522163829153852> <:beli:1190521869586145352>${obj.harga}`
  160.                     );
  161.                     arrCheck.push(obj.nama);
  162.                     if (!men.includes(obj.rolerank)) {
  163.                         men.push(obj.rolerank);
  164.                     }
  165.                 }
  166.                 continue;
  167.             }
  168.  
  169.             //cek kalok stock nya sama ap gak
  170.             let send2 = false;
  171.             for (let i = 0; i < split2.length; i++) {
  172.                 let dariMsg = split2[i];
  173.                 if (
  174.                     !arrCheck.includes(dariMsg) &&
  175.                     arrFruitsNama.includes(dariMsg)
  176.                 ) {
  177.                     send2 = true;
  178.                     break;
  179.                 }
  180.             }
  181.             //cek kalok send nya false dan sendtry nya kurang dari 10 atau sma dengan 10
  182.             if (!send2 && sendTry <= 10) {
  183.                 sendTry++;
  184.                 console.log(4);
  185.                 return;
  186.             }
  187.             cekIni++;
  188.             if (cekIni > 1) {
  189.                 send = false;
  190.                 cekIni = 0;
  191.                 console.log("cekini");
  192.                 return;
  193.             }
  194.  
  195.             send = false;
  196.             sendTry = 0;
  197.             let str = arrCheck.toString();
  198.             let menFix = men.join(" , ");
  199.             const sendMsg = await channelok.send(`stockbuah\n${str}\n`);
  200.             let jadi = arrayFruit.join("\n");
  201.             await webhookClient.send({
  202.                 content: `## ${typeStock} Fruit Stock\n${jadi}\n${menFix}\n<a:clock:1191357614920052797>**Next Stock In <t:${time}:R>!**\n## Credit To [RyuShin.store <a:emofix:1191299526527569930>](https://discord.gg/mCFt5ppBqW)`,
  203.                 flags: "SUPPRESS_EMBEDS",
  204.             });
  205.             after = +new Date();
  206.             after /= 1000;
  207.             timeExe = after - before;
  208.             await sendMsg.edit(
  209.                 `stockbuah\n${str}\ntotal time : ${timeExe}s\n${msg.url}\n`
  210.             );
  211.             return;
  212.         } catch (error) {
  213.             const guild1 = guild.get("1021954822116749332");
  214.             const channel = guild1.channels.cache.get("1189178957371818035"); //1189178957371818035
  215.             // console.log(channel);
  216.             channel.send(
  217.                 `<@819362961239703562>\n\`\`\`\n  ${error.message} \`\`\`\n  ${msg.url}\n`
  218.             );
  219.             return;
  220.         }
  221.     }
  222.     if (msg.channelId === "1114380738528301137") {
  223.         try {
  224.             await msg.crosspost();
  225.         } catch (err) {
  226.             console.error(err.message);
  227.         }
  228.     }
  229.     if (msg.author.id === "819362dqdw961239703562") {
  230.         let fruits = require("./fruit.json");
  231.         let arr = [];
  232.         let arrFruits = [
  233.             "Chop-Chop",
  234.             "Spring-Spring",
  235.             "Bomb-Bomb",
  236.             "Smoke-Smoke",
  237.             "Spike-Spike",
  238.             "Flame-Flame",
  239.             "Bird-Bird: Falcon",
  240.             "Ice-Ice",
  241.             "Sand-Sand",
  242.             "Dark-Dark",
  243.             "Diamond-Diamond",
  244.             "Light-Light",
  245.             "Rubber-Rubber",
  246.             "Barrier-Barrier",
  247.             "Ghost-Ghost",
  248.             "Magma-Magma",
  249.             "Quake-Quake",
  250.             "Buddha-Buddha",
  251.             "Love-Love",
  252.             "Spider-Spider",
  253.             "Sound-Sound",
  254.             "Bird-Bird: Phoenix",
  255.             "Portal-Portal",
  256.             "Rumble-Rumble",
  257.             "Paw-Paw",
  258.             "Blizzard-Blizzard",
  259.             "Gravity-Gravity",
  260.             "Mammoth-Mammoth",
  261.             "T-Rex-T-Rex",
  262.             "Dough-Dough",
  263.             "Shadow-Shadow",
  264.             "Venom-Venom",
  265.             "Control-Control",
  266.             "Spirit-Spirit",
  267.             "Dragon-Dragon",
  268.             "Leopard-Leopard",
  269.             "Kitsune-Kitsune",
  270.         ];
  271.  
  272.         for (let i = 0; i < arrFruits.length; i++) {
  273.             const fruit = arrFruits[i];
  274.             const buah = fruits[i];
  275.             // msg.guild.roles.cache.find((r) => r.name === fruit);
  276.             msg.guild.roles.cache.forEach((role) => {
  277.                 if (role.name === fruit) {
  278.                     const data = {
  279.                         fruit: buah.fruit,
  280.                         nama: buah.nama,
  281.                         emoji: buah.emoji,
  282.                         harga: buah.harga,
  283.                         rank: buah.rank,
  284.                         roleId: `<@&${role.id}>`,
  285.                         rolerank: buah.rolerank,
  286.                         color: buah.color,
  287.                     };
  288.                     arr.push(data);
  289.                 } else {
  290.                     return;
  291.                 }
  292.             });
  293.             // console.log(fruit);
  294.         }
  295.         // arrFruits.includes(role.name);
  296.         const push = JSON.stringify(arr);
  297.         fs.writeFile("fruits.json", push, function (err) {
  298.             if (err) throw err;
  299.             console.log("Saved!");
  300.         });
  301.         // msg.reply(`data ${arr.toString()}`);
  302.     }
  303.     return;
  304. });
  305.  
  306. // async function checkNotif() {
  307. //     const otaku = new OtakudesuInstance();
  308. //     const web = new WebhookClient({ url: process.env.WEB });
  309. //     console.log("Anime Notif On");
  310. //     (async () => {
  311. //         try {
  312. //             let f = false;
  313. //             do {
  314. //                 f = false;
  315. //                 const data = await anime.find();
  316. //                 for (const object of data) {
  317. //                     if (object.name === "Unknown" || object.id < 1) continue;
  318. //                     console.log(object.name);
  319. //                     let eps = Number(object.eps);
  320. //                     eps++;
  321. //                     let urlDown = object.urlDownload.replaceAll("epseps", eps);
  322. //                     let check = await otaku.getDownloadsByUrl(urlDown);
  323. //                     if (check.length === 0) continue;
  324. //                     console.log(checkk);
  325. //                     let resMKVRaw = [];
  326. //                     let resMp4Raw = [];
  327. //                     let resDown;
  328. //                     for (const url of check) {
  329. //                         const checkRes = ["720p", "1080p"];
  330. //                         resDown = url.resolution;
  331. //                         resDown = resDown.split(" ");
  332. //                         if (!checkRes.includes(resDown[1])) continue;
  333. //                         for (const object of url.links) {
  334. //                             const fileHost = object.name;
  335. //                             if (
  336. //                                 resDown[0].includes("Mp4") &&
  337. //                                 (fileHost.includes("ODFiles") ||
  338. //                                     fileHost.includes("GoFile"))
  339. //                             ) {
  340. //                                 resMp4Raw.push(
  341. //                                     `[${resDown[1]} ${fileHost}](${object.url})`
  342. //                                 );
  343. //                             }
  344. //                             if (
  345. //                                 resDown[0].includes("MKV") &&
  346. //                                 (fileHost.includes("ODFiles") ||
  347. //                                     fileHost.includes("GoFile"))
  348. //                             ) {
  349. //                                 resMKVRaw.push(
  350. //                                     `[${resDown[1]} ${fileHost}](${object.url})`
  351. //                                 );
  352. //                             }
  353. //                         }
  354. //                     }
  355. //                     eps = String(eps);
  356. //                     const newReq = await anime.findOneAndUpdate(
  357. //                         { id: object.id },
  358. //                         { eps: eps }
  359. //                     );
  360.  
  361. //                     const resMKV = resMKVRaw.join("\n");
  362. //                     const resMp4 = resMp4Raw.join("\n");
  363. //                     let downloadLinks = [];
  364. //                     if (resMKVRaw.length != 0) {
  365. //                         downloadLinks.push({ name: "MKV", value: resMKV });
  366. //                     }
  367. //                     if (resMp4Raw.length != 0) {
  368. //                         downloadLinks.push({ name: "MP4", value: resMp4 });
  369. //                     }
  370. //                     if (downloadLinks.length === 0) {
  371. //                         downloadLinks = [
  372. //                             { name: "MP4", value: "Download Links Not Found" },
  373. //                             { name: "MKV", value: "Download Links Not Found" },
  374. //                         ];
  375. //                     }
  376. //                     await send(newReq, eps, downloadLinks);
  377. //                 }
  378. //                 await sleep(1000 * 10);
  379. //                 f = true;
  380. //             } while (f === true);
  381. //             async function send(anime, eps, down) {
  382. //                 let urlDown = anime.urlDownload.replaceAll("epseps", eps);
  383. //                 const embed = new MessageEmbed()
  384. //                     .setAuthor({
  385. //                         name: "Otakudesu.cam",
  386. //                         url: "https://otakudesu.cam/",
  387. //                         iconURL:
  388. //                             "https://media.discordapp.net/attachments/1023214623249399888/1194471430964920410/Logo-1.png",
  389. //                     })
  390. //                     .setColor(`0x${anime.color}`)
  391. //                     .setDescription(
  392. //                         `[${anime.name}](${anime.url})\nEps : ${eps}/${anime.toEps}\n\n${anime.desc}`
  393. //                     )
  394. //                     .setImage(anime.imgUrl)
  395. //                     .setTitle(`${anime.name}\nEpisode ${eps}`)
  396. //                     .setURL(urlDown)
  397. //                     .setFields(down);
  398. //                 await web.send({
  399. //                     username: anime.namePfp,
  400. //                     avatarURL: anime.imgPfp,
  401. //                     content: anime.roleId,
  402. //                     embeds: [embed],
  403. //                 });
  404. //             }
  405. //             function sleep(ms) {
  406. //                 return new Promise((resolve) => setTimeout(resolve, ms));
  407. //             }
  408. //         } catch (err) {
  409. //             console.log(`Error : ` + err);
  410. //         }
  411. //     })();
  412. // }
  413.  
  414. //set ke 0
  415. //yang pas di 00     F:\Desktop\Bot\momo self\New folder\pas di 00.txt
  416. //
  417. (async () => {
  418.     cron.schedule(
  419.         "0 12 * * *",
  420.         () => {
  421.             nodeCron();
  422.         },
  423.         {
  424.             scheduled: true,
  425.             timezone: "Asia/Makassar",
  426.         }
  427.     );
  428.     cron.schedule(
  429.         "0 00 * * *",
  430.         () => {
  431.             nodeCron();
  432.         },
  433.         {
  434.             scheduled: true,
  435.             timezone: "Asia/Makassar",
  436.         }
  437.     );
  438.     cron.schedule(
  439.         "0 4 * * *",
  440.         () => {
  441.             nodeCron();
  442.         },
  443.         {
  444.             scheduled: true,
  445.             timezone: "Asia/Makassar",
  446.         }
  447.     );
  448.     cron.schedule(
  449.         "0 16 * * *",
  450.         () => {
  451.             nodeCron();
  452.         },
  453.         {
  454.             scheduled: true,
  455.             timezone: "Asia/Makassar",
  456.         }
  457.     );
  458.     cron.schedule(
  459.         "0 8 * * *",
  460.         () => {
  461.             nodeCron();
  462.         },
  463.         {
  464.             scheduled: true,
  465.             timezone: "Asia/Makassar",
  466.         }
  467.     );
  468.     cron.schedule(
  469.         "0 20 * * *",
  470.         () => {
  471.             nodeCron();
  472.         },
  473.         {
  474.             scheduled: true,
  475.             timezone: "Asia/Makassar",
  476.         }
  477.     );
  478. })();
  479.  
  480. async function nodeCron() {
  481.     send = true;
  482.     sendTry = 0;
  483.     cekIni = 0;
  484.     let get = new Date(+new Date());
  485.     get = Math.round(get / 1000);
  486.     time = get + 3600 * 4;
  487. }
  488.  
  489. client.login(process.env.TOKEN);
  490.  
  491. // client.on("message", message => {
  492. //     if (message.content.startsWith(prefix + "ping")) {
  493. //         message.channel.send('Pong! <:Pingsock:433019097005948938>');
  494.  
  495. //     } else if (message.content.startsWith(prefix + "avatar")) {
  496. //         message.reply(message.author.avatarURL);
  497.  
  498. //     }
  499. // });
  500.  
  501. // const ch = tempVars("ch");
  502. // const mem = tempVars("mem");
  503. // const name = mem.displayName;
  504. // const { MessageEmbed, WebhookClient } = require('discord.js');
  505. // const avatar = mem.displayAvatarURL({ dynamic: true });
  506. // require('dotenv').config()
  507.  
  508. // const embed = new MessageEmbed()
  509. //     .setDescription('## Notes\n- RyuShin.store **tidak akan bertanggung jawab** atas transaksi yang dilakukan dichannel ini\n- Jika ingin lebih aman, alangkah baiknya bisa memakai jasa MM(Middle Man) kami di<#1150064429292068964>')
  510. //     .setColor(0xff0000);
  511.  
  512. // send()
  513. // async function send() {
  514. //     try {
  515. //         await webhookClient.send({
  516. //             content: null,
  517. //             username: name,
  518. //             avatarURL: avatar,
  519. //             embeds: [embed],
  520. //             threadId: ch.id,
  521. //         });
  522. //         ch.lastMessage.pin();
  523. //         Actions.endActions(cache);
  524. //     } catch (error) {
  525. //         console.log(error.message)
  526. //     }
  527. // }
  528.  
  529. // const guild = await client.guilds.fetch('906426036772818954');
  530. // const channel = guild.channels.fetch('1037758983315931136');
  531. // const msg = await channel.messages.fetch({ limit: 100 });
  532. // const msg2 = await msg.channel.messages.fetch('1154024196695916574');
  533. // console.log(msg2);
  534.  
  535. // const guild = await client.guilds.fetch('906426036772818954');
  536. // const channel = await guild.channels.fetch('1037758983315931136');
  537. // // await messages.channel.fetch({ limit: 100 });
  538. // const msg = await channel.messages.fetch({ limit: 100 });
  539. // const msg2 = await msg.channel.messages.fetch('1154024196695916574');
  540. // console.log(msg);
  541.  
Advertisement
Add Comment
Please, Sign In to add comment