A easy to use discord economy package that use mongodb for storage.
npm install economy-manager.jsbash
npm i economy-manager.js
`
or
`bash
yarn add economy-manager.js
`
Import into your project.
`js
const { Client } = require('discord.js')
const client = new Client()const { EconomyManager } = require('economy-manager.js')
const eco = new EconomyManager()
`For examples check out example folder
Constructor option
misc - Enable built-in work method
`js
new EconomyManager({ misc: true })
`Methods
setUri - Set the mongodb uri.
`js
setUri(url: string)
`
Output
`sh
Void
`
fetch - Retrive a selected entry from database if it exist.
`js
fetch(userId: string, guildId: optional) // guildId is optional
`
Output
`sh
Promise`createUser - Add user in the database if the user doesn't exist.
`js
createUser(userId: string, guildId: optional)
`
Output
`sh
Promise`deleteUser - Delete a user from database.
`js
deleteUser(userId: string, guildId: )
`
Output
`sh
Promise
`fetch - Retrive user data from database.
`js
fetch(userId: string, guildId: )
`
Output
`sh
Promise`addMoney - Add user money to database.
`js
addMoney(amount: number, userId: string, guildId: )
`
Output
`sh
Promise`removeMoney - Remove user money from database.
`js
removeMoney(amount: number, userId: string, guildId: )
`
Output
`sh
Promise
`setMoney - Set a user money.
`js
setMoney(amount: number, userId: string, guildId: )
`
Output
`sh
Promise`work - A built-in work method with cooldowns.
`js
work(userId: string, guildId: )
`
Output
`sh
// Return raw cooldown number.
`Util class.
Import it to your project.
`js
const { Util } = require('economy-manager.js');
`
makeKey - Make a custom data key like quick.db
`js
Util.makeKey('your key name', 'key data', userId: string, guildId: )
`*fetchKey - Fetch the data from custom key.
`js
Util.fetchKey('key name', userId: string, guildId: string)
`
Output
`sh
Promise`getRawCooldown - Get the raw cooldow for work method.
`js
Util.getRawCooldown(userId: string, guildId: )
`
Output
`sh
`getParsedCooldown - Get the parsed cooldown for work method.
`js
getParsedCooldown(userId: string, guildId: )
`
Output
`sh
``