Advertisement
Zaayd

Credits / Rep / Daily Code DataBase({quick.db})

Jan 27th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on("message", async OmegaCodes => {
  2.   if(OmegaCodes.content.startsWith(`${prefix}rep`)){
  3.     let user = OmegaCodes.guild.member(OmegaCodes.mentions.users.first() || false);
  4.   if(!user) return OmegaCodes.channel.send(`**:rolling_eyes: | ${OmegaCodes.author.username}**, The user could not be found.`)
  5.   if(user.id == OmegaCodes.author.id) return OmegaCodes.channel.send(`**:rolling_eyes:  | ${OmegaCodes.author.username}, You cant give yourself a rep point !**`)
  6.   if(user.bot) return OmegaCodes.channel.send(`**:thinking:  | ${OmegaCodes.author.username} , bots do not have rep!**`)
  7.   let timeout = 8.64e+7;
  8.   let repotime = await db.fetch(`repotime_${OmegaCodes.author.id}`);
  9.   if(repotime !== null && timeout - (Date.now() - repotime > 0 )) {
  10.   let time = timeout - (Date.now() - repotime)
  11.       OmegaCodes.channel.send(`** <@${OmegaCodes.author.id}> , \n An error occurred when attempting to perform that request. Please check the Syntax and try again.**
  12. __Error__: \`You can claim again after ${ms(time, {verbose: true})}\``)
  13. } else {
  14.     OmegaCodes.channel.send(`** 🆙  |  ${OmegaCodes.author.username} has given ${user} a reputation point!**`)
  15.   await db.add(`rep_${user.id}`, 1);
  16.   await db.set(`repotime_${OmegaCodes.author.id}`, Date.now());
  17.   }
  18.   }
  19. });
  20.  
  21.  
  22. client.on("message" , async OmegaCodes => {
  23.   if(OmegaCodes.content.startsWith(`${prefix}daily`)){
  24.     await db.add(`credits_${OmegaCodes.author.id}`,1)
  25.     let amount = Math.floor(Math.random() * 4000) + 1;
  26.     let timeout = 8.64e+7;
  27.     if(OmegaCodes.author.bot) return OmegaCodes.channel.send(`**:thinking:  | bots do not have credits!**`)
  28.     let dailytime = await db.fetch(`dailytime_${OmegaCodes.author.id}`);
  29.     if(dailytime !== null && timeout - (Date.now() - dailytime > 0 )) {
  30.       let time = timeout - (Date.now() - dailytime)
  31.         OmegaCodes.channel.send(`** <@${OmegaCodes.author.id}> , \n An error occurred when attempting to perform that request. Please check the Syntax and try again.**
  32. __Error__: \`You can claim again after ${ms(time, {verbose: true})}\``)
  33.     } else {
  34.       OmegaCodes.channel.send(`**💰 ${OmegaCodes.author.username} , You git 💵  ${amount} daily  credits!**`)
  35.       await db.add(`credits_${OmegaCodes.author.id}`,parseInt(amount))
  36.       await db.set(`dailytime_${OmegaCodes.author.id}`, Date.now());
  37.     }
  38.   }
  39. });
  40.  
  41. let captcha = require("./captcha.json");
  42. client.on("message" , async OmegaCodes => {
  43.   await db.add(`credits_${OmegaCodes.author.id}`,1)
  44.   if(OmegaCodes.content.startsWith(`${prefix}credits`)){
  45.     let args = OmegaCodes.content.split(" ");
  46.     if(!args[2]){
  47.     let user = OmegaCodes.guild.member(OmegaCodes.mentions.users.first());
  48.     if (user) {
  49.       user = user.user
  50.     } else {
  51.       user = OmegaCodes.author
  52.     }
  53.     if(user.bot) return OmegaCodes.channel.send(`**:thinking:  | ${OmegaCodes.author.username} , bots do not have credits!**`)
  54.     let balance = await db.fetch(`credits_${user.id}`);
  55.     if(balance === null) balance = 0;
  56.      OmegaCodes.channel.send(`**:bank: | ${user.username} , your account balance is \`${balance}$\`**`)
  57.   } else if(args[2]){
  58.     let user = OmegaCodes.mentions.users.first();
  59.     if(user.id === OmegaCodes.author.id) return OmegaCodes.channel.send(`**:rolling_eyes:  | ${OmegaCodes.author.username}, You cant give yourself credits !**`)
  60.       let balance = await db.fetch(`credits_${OmegaCodes.author.id}`);
  61.       if(OmegaCodes.content.includes("-")) return OmegaCodes.channel.send("Negative money can not be transfer.")
  62.       if (balance < parseInt(args[2]))
  63.       return OmegaCodes.channel.send(`You don't have Enough credits to give to ${user.username}`)
  64.      if(parseInt(args[2]) < 1)
  65.      return OmegaCodes.channel.send(`You Must transfer credits above \`1\`.`)
  66.      if(isNaN(parseInt(args[2])))
  67.      return OmegaCodes.channel.send("Only Number")
  68.      let tax = Math.floor(args[2] * (5 / 100));
  69.      let Price = OmegaCodes.content.split(" ")[2];
  70.      let resulting = Math.floor(Price - Price * (5 / 100));
  71.      OmegaCodes.channel.send(`**${OmegaCodes.author.username}, Transfer Fees \`${tax}\`, Amount :\`${resulting}\` **\n type these numbers to confirm : `)
  72.      .then(m => {
  73.        const item = captcha[Math.floor(Math.random() * captcha.length)];
  74.          const filter = response => {
  75.    return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase());
  76. };
  77.          OmegaCodes.channel.send({
  78.            files: [{
  79.            attachment: item.type,
  80.            name: "capatcha.png"
  81.          }]
  82.      }).then(s => {
  83.        OmegaCodes.channel.awaitMessages(filter, { max: 1, time: 20000, errors: ['time'] })
  84.        .then(async (collected) => {
  85.        OmegaCodes.channel.send(
  86.            `**:moneybag: - ${OmegaCodes.author.username}, has transferred \`$${resulting}\` to ${user}**`
  87.          );
  88.          user.send(
  89.            `**:atm: | Transfer Receipt**\`\`\`You Have Received \$${resulting}\ From User ${OmegaCodes.author.username} (ID : ${OmegaCodes.author.id})\`\`\``
  90.          );
  91.          s.delete();
  92.          m.delete();
  93.          await db.add(`credits_${user.id}`, parseInt(resulting))
  94.          await db.subtract(`credits_${OmegaCodes.author.id}`,parseInt(Price))
  95.        })
  96.      });
  97.  });
  98.  }
  99. }
  100. });
  101.  
  102. //Captcha.json
  103. /*
  104. [
  105.    {
  106.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692002715672379413/captcha.png",
  107.        "answers": ["9340"]
  108.    },
  109.    {
  110.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692002857704095785/captcha.png",
  111.        "answers": ["2901"]
  112.    },
  113.    {
  114.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692002944660275310/captcha.png",
  115.        "answers": ["3735"]
  116.    },
  117.    {
  118.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003101883891762/captcha.png",
  119.        "answers": ["2414"]
  120.    },
  121.    {
  122.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003169428832368/captcha.png",
  123.        "answers": ["3517"]
  124.    },
  125.    {
  126.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003259379875840/captcha.png",
  127.        "answers": ["2643"]
  128.    },
  129.    {
  130.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003356226617415/captcha.png",
  131.        "answers": ["7175"]
  132.    },
  133.    {
  134.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003638301687857/captcha.png",
  135.        "answers": ["8705"]
  136.          },
  137.    {
  138.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003735693426719/captcha.png",
  139.        "answers": ["6281"]
  140.          },
  141.    {
  142.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003816475852860/captcha.png",
  143.        "answers": ["7331"]
  144.          },
  145.    {
  146.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003894963863663/captcha.png",
  147.        "answers": ["4062"]
  148.          },
  149.    {
  150.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692003969207238656/captcha.png",
  151.        "answers": ["8698"]
  152.          },
  153.    {
  154.            "type": "https://cdn.discordapp.com/attachments/634854460102803456/692004078858797086/captcha.png",
  155.        "answers": ["3865"]
  156.          }
  157. ]
  158. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement