constrandom=Math.floor(Math.random()*(max - min +1))+ min;//Number Generator, no need to touch as we already have min, max constant above.
client.on('message',async(message)=>{//Make sure Event Listener is Asynchrononous
if(message.author.bot)return;
awaiteco.give(message.author.id,message.guild.id, random);// Make Sure this Code is under Message Event Listener
})
Give Balance To User
//When you're using this Library, I assume you already know how to handle Arguments.
consteco=require('discord-mongoose-economy');
if(msg ==="give"){//give @shuncey 1000
if(!message.mentions.users.first())returnmessage.reply(`please mention a user.`);
if(!args[2])returnmessage.reply('please specify an amount.');
constgive=awaiteco.give(message.mentions.users.first().id,message.guild.id, args[2]);//Creates a new entry in the DB if User doesn't Exist.
message.reply(`I gave ${message.mentions.users.first()}${give.amount}`);
}
Deduct User Balance
consteco=require('discord-mongoose-economy');
if(msg ==="deduct"){//deduct @shuncey 1000
if(!message.mentions.users.first())returnmessage.reply(`please mention a user.`);
if(!args[2])returnmessage.reply('please specify an amount.');
constdeduct=awaiteco.deduct(message.mentions.users.first().id,message.guild.id, args[2]);//Creates a new entry in the DB if User doesn't Exist.
message.reply(`I deducted ${deduct.amount} from ${message.mentions.users.first()} wallet.`);
}
Give User More Bank Capacity
consteco=require('discord-mongoose-economy');
if(msg ==="givebankcap"){
if(!message.mentions.users.first())returnmessage.reply(`please mention a user.`);
if(!args[2])returnmessage.reply('please specify an amount to add to bank space.');
constadd=eco.giveCapacity(message.mentions.users.first().id,message.guild.id, args[2]);//If the user doesn't exist in the Database, it makes one. Bank Capacity Will Be 2500(Default)+Amount you specified.
}
Create User
consteco=require('discord-mongoose-economy');
if(msg ==="create"){
if(!message.mentions.users.first())returnmessage.reply(`Please mention a user.`);
if(!delete.exists)returnmessage.reply('User doesn\'t exist');//exists[boolean] whether the user exist in the database or not. in this case we are checking if user exists(exists === true), if it does exists.
message.reply(`Removed ${message.mentions.users.first()} to the database`);
constdaily=awaiteco.daily(message.author.id,message.guild.id,500);//give 500 for daily, can be changed
if(daily.cd)returnmessage.reply(`Daily on cooldown come back in ${daily.cdL}`);//cdL is already formatted cooldown Left
message.reply(`you claimed ${daily.amount} for daily`);
}
Deposit and Withdraw
consteco=require('discord-mongoose-economy');
if(msg ==="deposit"){
if(args[1]!=="all"&&isNaN(args[1]))returnmessage.reply('not valid');//deposit only accepts integers or string "all" which deposits all from the users wallet.
if(deposit.noten)returnmessage.reply('You can\'t deposit what you don\'t have.');//if user states more than whats in his wallet
message.reply(`Deposited ${deposit.amount} to your bank.`)
}
if(msg ==="withdraw"){
if(args[1]!=="all"&&isNaN(args[1]))returnmessage.reply('not valid');//withdraw only accepts integers or string "all" which deposits all from the users wallet.