Installation
$ npm install --save discord-leveling
Checkout my package for economy systems on discord bots! discord-economy
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.1.0 Finally back! For now only some typo fixes and cleaner code.
SetXp
/** * @param * @param */ var leveling = leveling /**Expected Promise Output{userid, xp} */
SetLevel
/*** @param* @param */ var leveling = leveling /**Expected Promise Output{userid, level} */
AddXp
/*** @param* @param */ var leveling = leveling /**Expected Promise Output{userid, oldxp, newxp} */
AddLevel
/*** @param* @param */ var leveling = leveling /**Expected Promise Output{userid, oldlevel, newlevel} */
Leaderboard
/** * @param All keys in this object are optional. * @param * @param */ var leveling = leveling /**Expected Promise Output without data.search[ {userid, level, xp}, {userid, level, xp}, {userid, level, xp} ]array[0] is the first place of the leaderboard. array[1] second etc. */ /**Expected Promise Output with data.search{userid, placement} */
Fetch
/** * @param */ var leveling = leveling /**Expected Promise Output{userid, xp, level} */
Delete
/** * @param */var leveling = leveling /**Expected Promise Output */
Example Bot (discord.js)
/*If you want to make discord-leveling guild based you have to use message.author.id + message.guild.id as ID for example:leveling.AddLevel(message.author.id + message.guild.id, toAdd).then(l => console.log(l)) This will create an unique ID for each guild member*/ //Requiring Packagesconst Discord = ; //This can also be discord.js-commando or other node based packages!const leveling = ; //Create the bot clientconst client = ; //Set the prefix and token of the bot.const settings = prefix: ';' token: 'YOUR TOKEN' //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