forked from Ramlan404/babybot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,820 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[] | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
const fs = require('fs') | ||
|
||
/** | ||
* Add AFK. | ||
* @param {String} userId | ||
* @param {String} time | ||
* @param {String} reason | ||
* @param {Object} _dir | ||
*/ | ||
const addAfkUser = (userId, time, reason, _dir) => { | ||
const obj = { id: userId, time: time, reason: reason } | ||
_dir.push(obj) | ||
fs.writeFileSync('./database/afk.json', JSON.stringify(_dir)) | ||
} | ||
|
||
/** | ||
* Check user AFK. | ||
* @param {String} userId | ||
* @param {Object} _dir | ||
* @returns {Boolean} | ||
*/ | ||
const checkAfkUser = (userId, _dir) => { | ||
let status = false | ||
Object.keys(_dir).forEach((i) => { | ||
if (_dir[i].id === userId) { | ||
status = true | ||
} | ||
}) | ||
return status | ||
} | ||
|
||
/** | ||
* Get AFK reason. | ||
* @param {String} userId | ||
* @param {Object} _dir | ||
* @returns {String} | ||
*/ | ||
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 | ||
} | ||
} | ||
|
||
/** | ||
* Get AFK time. | ||
* @param {String} userId | ||
* @param {Object} _dir | ||
* @returns {String} | ||
*/ | ||
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 | ||
} | ||
} | ||
|
||
/** | ||
* Get AFK ID. | ||
* @param {String} userId | ||
* @param {Object} _dir | ||
* @returns {String} | ||
*/ | ||
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 | ||
} | ||
} | ||
|
||
/** | ||
* Get AFK position. | ||
* @param {String} userId | ||
* @param {Object} _dir | ||
* @returns {Number} | ||
*/ | ||
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 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.