{"size": 1694, "ext": "js", "max_stars_repo_path": "commands/economy/deposit.js", "max_stars_repo_name": "FearTheRenegade/FennecBot", "max_stars_repo_stars_event_min_datetime": "2019-04-29T06:18:07.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-29T06:18:07.000Z", "max_issues_repo_path": "commands/economy/deposit.js", "max_issues_repo_name": "FearTheRenegade/FennecBot", "max_issues_repo_issues_event_min_datetime": "2021-05-08T17:10:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T04:29:41.000Z", "max_forks_repo_path": "commands/economy/deposit.js", "max_forks_repo_name": "FearTheRenegade/FennecBot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 29.2068965517, "max_line_length": 128, "alphanum_fraction": 0.5011806375}
﻿
module.exports = {
    name: 'deposit',
    description: 'Deposit your money',
    usage: '//deposit <money>',
    cooldown: 1,
    execute(client, message, args, sql) {

        const money = parseInt(args);

        var content = message.content;
        var parts = content.split(" ");
        var check = parts[1];

        client.getEco = sql.prepare("SELECT * FROM economy WHERE id = ?");
        client.setEco = sql.prepare("INSERT OR REPLACE INTO economy (id, cash, bank, user) VALUES (@id, @cash, @bank, @user);");
        Eco = client.getEco.get(message.author.id);

        if (!Eco) {

            return message.reply(`You don't have an Eco account setup! Do //money and then come back to this command.`);

        } else {

            if (!check) {

                return message.reply("I can't deposit nothing! Please specify the amount!")

            } else {

                if (!isNaN(money) && money > 0) {

                    if (Eco.cash >= money) {

                        let mon = client.getEco.get(message.author.id);

                        mon.bank = parseInt(mon.bank) + money; // Needs to be on top to deposit first, then take out cash.

                        mon.cash = parseInt(mon.cash) - money;

                        client.setEco.run(mon);

                        return message.reply(`$${money} has been deposited into your bank. Now it can't be stolen!`)

                    } else {

                        return message.reply("HAH YOU'RE TOO POOR FOR THAT!")

                    }
                } else {

                    return message.reply(`Please specify a correct number.`);

                }
            }
        }
    },
};