forked from Ilhamskhyi/botv1-Md
-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelup.js
28 lines (24 loc) · 814 Bytes
/
levelup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let levelling = require('../lib/levelling')
let handler = async(m, { conn, usedPrefix, command }) => {
let user = global.db.data.users[m.sender]
if (!levelling.canLevelUp(user.level, user.exp, global.multiplier)) {
let { min, xp, max } = levelling.xpRange(user.level, global.multiplier)
throw `
Level *${user.level} (${user.exp - min}/${xp})*
Kurang *${max - user.exp}* lagi!
`.trim()
}
let before = user.level * 1
while (levelling.canLevelUp(user.level, user.exp, global.multiplier)) user.level++
if (before !== user.level) {
m.reply(`
Selamat, anda telah naik level!
*${before}* -> *${user.level}*
gunakan *${usedPrefix + command}* untuk mengecek
`.trim())
}
}
handler.help = ['levelup']
handler.tags = ['xp']
handler.command = /^level(|up)$/i
module.exports = handler