Anything problem conctact here
Required packages
npm i economy-mongoose
//Or the equivalent of
yarn add economy-mongoose
//Or others
Typescript:
import {Economy} from "economy-mongoose"
Economy.connect("MongoDB connection")
Javascript:
const {Economy} = require("economy-mongoose")
Economy.connect("MongoDB connection")
Methods:
Economy.createUser(UserID, GuildID) // Create a user in the database.
Economy.DeleteUser(UserID, GuildID) // Delete a user in the database.
Economy.getUser(UserID, GuildID) // Gets a user from the database.
Economy.addWallet(UserID, GuildID, Amount) // Add money to a user's wallet.
Economy.removeWallet(User, Guild, Amount) // Remove money from a user's wallet.
Economy.removeBank(User, Guild, Amount) // Remove money from a user's bank.
Economy.addBank(User, Guild, Amount) // Add money to a user's bank.
Economy.Withdraw(User, Guild, Amount) // Take money out of the bank to use it in the wallet.
Economy.transfer(FromUserID, ToUserID, Guild, Amount)//Transfer from one user to another user an amount of money
Economy.Deposit(User, Guild, Amount) // Deposit money from the wallet to the bank.
Economy.setBank(User, Guild, Amount) //Set an amount in someone's bank.
Economy.setWallet(User, GuildID, Amount) //Set an amount in someone's wallet.
Returns, types and errors in code:
Parameter Amount
+ Amount is necessarily a Number
- If Amount is not a Number it returns false
- If Amount has an error it returns false, otherwise true
Parameter UserID, FromUserID and ToUserID
+ User is necessarily a String
- If User has an error it returns false, otherwise true
Parameter Guild
+ Guild is necessarily a String
- If Guild has an error it returns false, otherwise true
Error getUser
+ const user = await Economy.getUser( User, Guild ); //Return the true
- const user = Economy.getUser( User, Guild );//Return undefined in all
Every time we use the get or another that consists of variables, you must use await
In the case of deposit, withdraw or others are used like this
Economy.deposit()
Properties:
let user = await Economy.getUser(UserID, GuildID)
user.User // Access a user.
user.Bank//Access someone's bank.
user.Wallet // You access a user's wallet.
user.Guild // You access a server/guild.
let user = await Economy.getUser(USER, GUILD)
console.log('Money', user.Wallet)
console.log('Bank', user.Bank)
console.log('Money in total', user.bank+user.Wallet)
const {Economy} = require("economy-mongoose")//Require the package
Economy.transfer(FROM, TO, GUILD, AMOUNT)