// DEPOSIT COMMAND const profileModel = require("../models/profileSchema"); module.exports = { name: "deposit", aliases: ["dep"], permissions: [], description: "Deposit coins into your bank!", async execute(message, args, cmd, client, discord, profileData) { const amount = args[0]; if (amount % 1 != 0 || amount <= 0) return message.channel.send("Deposit amount must be a whole number"); try { if (amount > profileData.coins) return message.channel.send(`You don't have that amount of coins to deposit`); await profileModel.findOneAndUpdate( { userID: message.author.id, }, { $inc: { coins: -amount, bank: amount, }, } ); return message.channel.send(`You deposited ${amount} of coins into your bank`); } catch (err) { console.log(err); } }, }; //WITHDRAW COMMAND const profileModel = require("../models/profileSchema"); module.exports = { name: "withdraw", aliases: ["wd"], permissions: [], description: "withdraw coins from your bank", async execute(message, args, cmd, client, discord, profileData) { const amount = args[0]; if (amount % 1 != 0 || amount <= 0) return message.channel.send("Withdrawn amount must be a whole number"); try { if (amount > profileData.bank) return message.channel.send(`You don't have that amount of coins to withdraw`); await profileModel.findOneAndUpdate( { userID: message.author.id, }, { $inc: { coins: amount, bank: -amount, }, } ); return message.channel.send(`You withdrew ${amount} of coins into your wallet`); } catch (err) { console.log(err); } }, }; //GIVE COMMAND const profileModel = require("../models/profileSchema"); module.exports = { name: "give", aliases: [], permissions: ["ADMINISTRATOR"], description: "give a player some coins", async execute(message, args, cmd, client, discord, profileData) { if (message.member.id != "206231395989716992") return message.channel.send(`Sorry only **Alesh** can run this command 😔`); if (!args.length) return message.channel.send("You need to mention a player to give them coins"); const amount = args[1]; const target = message.mentions.users.first(); if (!target) return message.channel.send("That user does not exist"); if (amount % 1 != 0 || amount <= 0) return message.channel.send("Deposit amount must be a whole number"); try { const targetData = await profileModel.findOne({ userID: target.id }); if (!targetData) return message.channel.send(`This user doens't exist in the db`); await profileModel.findOneAndUpdate( { userID: target.id, }, { $inc: { coins: amount, }, } ); return message.channel.send(`This player has been given their coins! ${amount} of coins!`); } catch (err) { console.log(err); } }, };