{"size": 2577, "ext": "js", "max_stars_repo_path": "commands/economy/fish.js", "max_stars_repo_name": "Mayank-theDev/BombaBot", "max_stars_repo_stars_event_min_datetime": "2021-02-27T04:09:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-29T05:33:34.000Z", "max_issues_repo_path": "commands/economy/fish.js", "max_issues_repo_name": "Mayank-theDev/BombaBot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/economy/fish.js", "max_forks_repo_name": "Mayank-theDev/BombaBot", "max_forks_repo_forks_event_min_datetime": "2020-11-27T15:21:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-27T15:21:54.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 31.8148148148, "max_line_length": 141, "alphanum_fraction": 0.5739231665}
const fishes = require("../../JSON/fishes.json");
let db = require("quick.db");
const ms = require("parse-ms");
const { randomRange } = require("../../functions");
const { MessageEmbed } = require("discord.js");

module.exports = {
  name: "fish",
  aliases: ["catchfish"],
  category: "economy",
  description: "Catch A Fish From A Vast Ocean",
  usage: "[list | rewards] (optional)",
  acessableby: "everyone",

  run: async (bot, message, args) => {
    let user = message.author;

    let bal = db.fetch(`money_${user.id}`);

    let fish = await db.fetch(`fish_${user.id}`);
    if (!args[0]) {
      if (bal === null) bal = 0;

      if (fish == null) fish = 0;

      const fishID = Math.floor(Math.random() * 10) + 1;
      let rarity;
      if (fishID < 5) rarity = "junk";
      else if (fishID < 8) rarity = "common";
      else if (fishID < 9) rarity = "uncommon";
      else if (fishID < 10) rarity = "rare";
      else rarity = "legendary";
      const fishh = fishes[rarity];
      const worth = randomRange(fishh.min, fishh.max);

      let timeout = 1800000;
      let fishtime = await db.fetch(`fishtime_${user.id}`);

      if (fishtime !== null && timeout - (Date.now() - fishtime) > 0) {
        let time = ms(timeout - (Date.now() - fishtime));

        let timeEmbed = new MessageEmbed()
          .setColor("RANDOM")
          .setDescription(
            `<:bombacross:764545831285817374> Looks like you just retuned from the pond \n\nFish Again in ${time.minutes}m ${time.seconds}s `
          );
        return message.channel.send(timeEmbed);
      }

      let embed = new MessageEmbed()
        .setColor("RANDOM")
        .setDescription(
          `**🎣 Woah you got it ${fishh.symbol}, The fishes caught by you are worth ${worth}**!`
        );
      message.channel.send(embed);

      db.add(`money_${user.id}`, worth);
      db.add(`fish_${user.id}`, 1);
      db.set(`fishtime_${user.id}`, Date.now());
    }
    if (args[0] === "list" || args[0] === "rewards") {
      let lEmbed = new MessageEmbed()
        .setColor("RANDOM")
        .setTitle(`List Of Fish Names And Rewards You Can Get`)
        .setDescription(
          `
\`\`\`🔧Junk      :: Max Reward: 5, Min Reward: 1
🐟Common    :: Max Reward: 25, Min Reward: 10
🐠Uncommon  :: Max Reward: 50, Min Reward: 18
🦑Rare      :: Max Reward: 75, Min Reward: 30
🐋Legendary :: Max Reward: 100, Min Reward: 50\`\`\`
**All reward are random from max/min**
​
`
        )
        .setFooter(message.guild.name, message.guild.iconURL());
      return message.channel.send(lEmbed);
    }
  }
};
