economy-manager.js
v0.0.4
Published
A easy to use discord economy package that use mongodb for storage.
Downloads
11
Maintainers
Readme
economy-manager.js
An easy to use discord economy package and use mongodb to store data.
Installation
npm i economy-manager.js
or
yarn add economy-manager.js
Import into your project.
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
new EconomyManager({ misc: true })
Methods
setUri - Set the mongodb uri.
setUri(url: string)
Output
Void
fetch - Retrive a selected entry from database if it exist.
fetch(userId: string, guildId: optional) // guildId is optional
Output
Promise<Object>
createUser - Add user in the database if the user doesn't exist.
createUser(userId: string, guildId: optional)
Output
Promise<Object>
deleteUser - Delete a user from database.
deleteUser(userId: string, guildId: <optional/string>)
Output
Promise<Boolean/Object>
fetch - Retrive user data from database.
fetch(userId: string, guildId: <optional/string>)
Output
Promise<Object>
addMoney - Add user money to database.
addMoney(amount: number, userId: string, guildId: <optional/string>)
Output
Promise<Object>
removeMoney - Remove user money from database.
removeMoney(amount: number, userId: string, guildId: <optional/string>)
Output
Promise<Boolean/Object>
setMoney - Set a user money.
setMoney(amount: number, userId: string, guildId: <optional/string>)
Output
Promise<Object>
work - A built-in work method with cooldowns.
work(userId: string, guildId: <optional/string>)
Output
<Number> // Return raw cooldown number.
Util class.
Import it to your project.
const { Util } = require('economy-manager.js');
makeKey - Make a custom data key like quick.db
Util.makeKey('your key name', 'key data', userId: string, guildId: <optional/string>)
*fetchKey - Fetch the data from custom key.
Util.fetchKey('key name', userId: string, guildId: string)
Output
Promise<Object>
getRawCooldown - Get the raw cooldow for work method.
Util.getRawCooldown(userId: string, guildId: <optional/string>)
Output
<Number>
getParsedCooldown - Get the parsed cooldown for work method.
getParsedCooldown(userId: string, guildId: <optional/string>)
Output
<String>