forked from elrebelde21/LoliBot-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgivegold.js
80 lines (70 loc) ยท 3.16 KB
/
givegold.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const petik = '```'
const items = ['credit', 'exp']
let confirmation = {}
async function handler(m, { conn, args, usedPrefix, command }) {
if (confirmation[m.sender]) return m.reply('ุฃูุช ุชููู
ุจุงูุชุญููู')
let user = global.db.data.users[m.sender]
const item = items.filter(v => v in user && typeof user[v] == 'number')
let lol = `โณ๏ธ Correct use of the command
*${usedPrefix + command}* credit [amount] [@user]
๐ ู
ุซุงู :
*${usedPrefix + command}* ุนู
ูู 1000 @${m.sender.split('@')[0]}
`.trim()
const type = (args[0] || '').toLowerCase()
if (!item.includes(type)) return conn.reply(m.chat, lol, m, { mentions: [m.sender] })
const count = Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, (isNumber(args[1]) ? parseInt(args[1]) : 1))) * 1
let who = m.mentionedJid && m.mentionedJid[0] ? m.mentionedJid[0] : args[2] ? (args[2].replace(/[@ .+-]/g, '') + '@s.whatsapp.net') : ''
if (!who) return m.reply('โณ๏ธ ุถุน ุนูุงู
ุฉ ุนูู ุงูู
ุณุชุฎุฏู
')
if (!(who in global.db.data.users)) return m.reply(`โณ๏ธ ุงูู
ุณุชุฎุฏู
ููุณ ูู ูุงุนุฏุฉ ุงูุจูุงูุงุช ุงูุฎุงุตุฉ ุจู`)
if (user[type] * 1 < count) return m.reply(`โณ๏ธ *${type}* ุบูุฑ ูุงููุฉ ููููู`)
let confirm = `
ูู ุฃูุช ู
ุชุฃูุฏ ุฃูู ุชุฑูุฏ ุงูููู *โน${count}* to *@${(who || '').replace(/@s\.whatsapp\.net/g, '')}* ?
- Have *60s*
Reply ${petik}Yes${petik} or ${petik}no${petik}
`.trim()
m.reply(ูุชุฃูุฏ, null, { mentions: [who] })
confirmation[m.sender] = {
sender: m.sender,
to: who,
message: m,
type,
count,
timeout: setTimeout(() => (m.reply('โณ ุงูุชูู ุงูููุช'), delete confirmation[m.sender]), 60 * 1000)
}
}
handler.before = async m => {
if (m.isBaileys) return
if (!(m.sender in confirmation)) return
if (!m.text) return
let { timeout, sender, message, to, type, count } = confirmation[m.sender]
if (m.id === message.id) return
let user = global.db.data.users[sender]
let _user = global.db.data.users[to]
if (/no?/g.test(m.text.toLowerCase())) {
clearTimeout(timeout)
delete confirmation[sender]
return m.reply('โ
ุชู
ุฅูุบุงุก ุงูููู')
}
if (/yes?/g.test(m.text.toLowerCase())) {
let previous = user[type] * 1
let _previous = _user[type] * 1
user[type] -= count * 1
_user[type] += count * 1
if (previous > user[type] * 1 && _previous < _user[type] * 1) m.reply(`ุนู
ููุฉ ูุงุฌุญุฉ โ
\n\n*โน${count}* ุชู
ูููู ุงูู @${(to || '').replace(/@s\.whatsapp\.net/g, '')}`, null, { mentions: [to] })
else {
user[type] = previous
_user[type] = _previous
m.reply(`โ ูุดู ุงูููู *${count}* ${type} a *@${(to || '').replace(/@s\.whatsapp\.net/g, '')}*`, null, { mentions: [to] })
}
clearTimeout(timeout)
delete confirmation[sender]
}
}
handler.help = ['give'].map(v => v + ' credit [amount] [@tag]')
handler.tags = ['economy']
handler.command = ['payxp', 'ุชุญููู', 'give']
handler.disabled = false
export default handler
function isNumber(x) {
return !isNaN(x)
}