Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jajbshjahavahh
GitHub Repository: jajbshjahavahh/Gojo-Satoru
Path: blob/master/storage/user/limit.js
2591 views
1
const fs = require('fs')
2
let _limitOrg = JSON.parse(fs.readFileSync('./storage/user/limit.json'))
3
let limitAwal = global.limitawal.free
4
const addInventoriLimit = (sender) => {
5
const obj = {id: sender, limit: limitAwal}
6
_limitOrg.push(obj)
7
fs.writeFileSync('./storage/user/limit.json', JSON.stringify(_limitOrg))
8
}
9
const cekDuluJoinAdaApaKagaLimitnyaDiJson = (sender) => {
10
let status = false
11
Object.keys(_limitOrg).forEach((i) => {
12
if (_limitOrg[i].id === sender) {
13
status = true
14
}
15
})
16
return status
17
}
18
const addLimit = (sender, amount) => {
19
let position = false
20
Object.keys(_limitOrg).forEach((i) => {
21
if (_limitOrg[i].id === sender) {
22
position = i
23
}
24
})
25
if (position !== false) {
26
_limitOrg[position].limit += amount
27
fs.writeFileSync('./storage/user/limit.json', JSON.stringify(_limitOrg))
28
}
29
}
30
const kurangLimit = (sender, amount) => {
31
let position = false
32
Object.keys(_limitOrg).forEach((i) => {
33
if (_limitOrg[i].id === sender) {
34
position = i
35
}
36
})
37
if (position !== false) {
38
_limitOrg[position].limit -= amount
39
fs.writeFileSync('./storage/user/limit.json', JSON.stringify(_limitOrg))
40
}
41
}
42
const getLimit = (sender) => {
43
let position = false
44
Object.keys(_limitOrg).forEach((i) => {
45
if (_limitOrg[i].id === sender) {
46
position = i
47
}
48
})
49
if (position !== false) {
50
return _limitOrg[position].limit
51
}
52
}
53
54
module.exports = { addInventoriLimit, cekDuluJoinAdaApaKagaLimitnyaDiJson, addLimit, kurangLimit, getLimit }
55