forked from elrebelde21/LoliBot-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchickenfight.js
81 lines (62 loc) ยท 2.84 KB
/
chickenfight.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
81
let handler = async (m, { conn, args, text, usedPrefix , command }) => {
/*if (global.db.data.users[m.sender].level < 5) {
return conn.reply(m.chat, 'You must be at least level 5 to use this command.', m);
}*/
let fa = `๐ฅ *ุชูููุฑ ูู
ูุฉ ุงูุฐูุจ ููู
ุฑุงููุฉ*
*Example:*
${usedPrefix + command} 1000`.trim()
if (!args[0]) throw fa
if (isNaN(args[0])) throw fa
let users = global.db.data.users[m.sender]
let credit = users.credit
let amount = (args[0] && number(parseInt(args[0])) ? Math.max(parseInt(args[0]), 1) : /all/i.test(args[0]) ? Math.floor(parseInt(users.credit)) : 1) * 1
let time = users.lastcf + 90000
if (new Date - users.lastcf < 90000) throw `ูู
ููู ูุนุจ ู
ุตุงุฑุนุฉ ุงูุฏููุฉ ู
ุฑุฉ ุฃุฎุฑู ${msToTime(time - new Date())}`
if (amount < 100) throw `๐ฅ *ูุง ูู
ููู ุงูู
ุฑุงููุฉ ุจุงูุฐูุจ ุจุฃูู ู
ู 100*`
if (users.credit < amount) throw `๐ฅ *ููุณ ูุฏูู ู
ุง ูููู ู
ู ุงูู
ุงู ููุฐุง ุงูุฑูุงู.*\n*ูุฏูู ุญุงูููุง ููุท ${credit} ูู ุงูุฐูุจ.*`
if (users.chicken < 1) {
throw `๐ฅ *ููุณ ูุฏูู ุฃู ุงููุชุงููุช ููู
ุฑุงููุฉ* \nุงุณุชุฎุฏู
ุงูุฃู
ุฑ ${usedPrefix}buy-chicken`
}
//if (amount > 100000) throw `๐ฅ *ูุง ูู
ููู ุงูู
ุฑุงููุฉ ุจุงูุฐูุจ ุจุฃูุซุฑ ู
ู 100000*`
let botScore = (Math.ceil(Math.random() * 35)) * 1 // Random score for the bot (1 to 51)
let playerScore = (Math.floor(Math.random() * 101)) * 1 // Random score for the player (1 to 100)
let status = `Your chicken died ๐ชฆ`
if (botScore < playerScore) {
users.credit += amount * 1
status = `ููุฏ ูุงุฒุช ุฏุฌุงุฌุชู ุงูุตุบูุฑุฉ ูู ุงูู
ุนุฑูุฉุ ูุตูุนุชู ๐ช ${amount * 2} ุงูุฐูุจ ุฃูุซุฑ ุซุฑุงุก! ๐ฅ`
} else {
users.credit -= amount * 1
users.chicken -= 1
users.lastcf = new Date * 1
}
let result = `${status}
`.trim()
m.reply(result)
}
handler.help = ['cock-fight <amount>']
handler.tags = ['economy']
handler.command = ['cock-fight', 'ุฑูุงู']
handler.group = true
export default handler
function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24)
hours = (hours < 10) ? "" + hours : hours
minutes = (minutes < 10) ? "" + minutes : minutes
seconds = (seconds < 10) ? "" + seconds : seconds
return minutes + " minutes " + seconds + " seconds"
}
function pickRandom(list) {
return list[Math.floor(list.length * Math.random())]
}
/**
* Detect if thats number
* @param {Number} x
* @returns Boolean
*/
function number(x = 0) {
x = parseInt(x)
return !isNaN(x) && typeof x == 'number'
}