-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathafk.js
75 lines (73 loc) · 1.77 KB
/
afk.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
//base by Tech-God
//re-upload? recode? copy code? give credit ya :)
//YouTube: @techgod143
//Instagram: techgod143
//Telegram: t.me/techgod143
//GitHub: @techgod143
//WhatsApp: +917466008456
//want more free bot scripts? subscribe to my youtube channel: https://youtube.com/@techgod143
const fs = require('fs')
const addAfkUser = (userId, time, reason, _dir) => {
const obj = { id: userId, time: time, reason: reason }
_dir.push(obj)
fs.writeFileSync('./database/afk-user.json', JSON.stringify(_dir, null, 2))
}
const checkAfkUser = (userId, _dir) => {
let status = false
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
status = true
}
})
return status
}
const getAfkReason = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
if (position !== null) {
return _dir[position].reason
}
}
const getAfkTime = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
if (position !== null) {
return _dir[position].time
}
}
const getAfkId = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
if (position !== null) {
return _dir[position].id
}
}
const getAfkPosition = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
return position
}
module.exports = {
addAfkUser,
checkAfkUser,
getAfkReason,
getAfkTime,
getAfkId,
getAfkPosition
}