Installation
$ npm install --save discord-economy
Checkout my package for xp systems on discord bots! discord-leveling
Required packages
- sequelize the DB wrapper of sqlite3 of this project (
npm install --save sequelize
) - sqlite3 Core DB (
npm install --save sqlite3
)
Optional
- discord.js - (
npm install --save discord.js
) - discord.js-commando - (
npm install --save discord.js-commando
) - eris - (
npm install --save eris
)
Changelog
- 1.2.2 Finally back! Substractfrombalance -> SubtractFromBalance (Typo Fix). Created Slots function.
Functions
SetBalance
/** * @param * @param */ var eco = eco /**Expected Promise Output{userid, balance} */
AddToBalance
/** * @param * @param */ var eco = eco /**Expected Promise Output{userid, oldbalance, newbalance} */
SubtractFromBalance
/** * @param * @param */ var eco = eco /**Expected Promise Output{userid, oldbalance, newbalance} */
FetchBalance
/** * @param */ var eco = eco /**Expected Promise Output{userid, balance} */
Leaderboard
/** * @param All keys in this object are optional. * @param * @param */ var eco = eco /**Expected Promise Output without data.search[ {userid, balance}, {userid, balance}, {userid, balance} ]array[0] is the first place of the leaderboard. array[1] second etc. */ /**Expected Promise Output with data.search{userid, balance} */
Daily
/** * @param */ var eco = eco /**Expected Promise Output{userid, updated, timetowait} */
ResetDaily
/** * @param */ var eco = eco /**Expected Promise Output('Daily Reset.') */
Transfer
/** * @param * @param * @param */ var eco = eco /**Expected Promise Output{FromUser, ToUser} */
Coinflip
/*** @param* @param* @param */ var eco = eco}) /**Expected Promise Output{userid, oldbalance, newbalance, output} */
Dice
/*** @param* @param* @param */ var eco = eco /**Expected Promise Output{userid, oldbalance, newbalance, guess, dice, output} */
Delete
/** * @param */var eco = eco /**Expected Promise Output */
Work
/** * @param * @param All keys in this object are optional. They have a default fallback. * @param * @param * @param */ var eco = eco /**Expected Promise Output{userid, earned, job, balance} */
Slots
/*** @param* @param* @param All keys in this object are optional.* @param* @param* @param*/ */ var eco = eco /**Expected Promise Output{userid, oldbalance, newbalance, grid, output} */
Example Bot (discord.js)
/*If you want to make discord-economy guild based you have to use message.author.id + message.guild.id as ID for example:eco.Daily(message.author.id + message.guild.id) This will create a unique ID for each guild member*/ //Requiring Packagesconst Discord = ; //This can also be discord.js-commando or other node based packages!const eco = ; //Create the bot clientconst client = ; //Set the prefix and token of the bot.const settings = prefix: ';' token: 'YOURTOKEN' //Whenever someone types a message this gets activated.//(If you use 'await' in your functions make sure you put async here)client; //Your secret token to log the bot in. (never show this to anyone!)client