Skip to content

Commit

Permalink
hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavyanDesu committed Feb 8, 2021
1 parent 6d342f5 commit fab2ec3
Show file tree
Hide file tree
Showing 18 changed files with 336 additions and 343 deletions.
50 changes: 25 additions & 25 deletions function/afk.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require('fs-extra')

/**
* Add AFK.
* @param {String} userId
* @param {String} time
* @param {String} reason
* @param {Object} _dir
* Add AFK user.
* @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 }
Expand All @@ -14,10 +14,10 @@ const addAfkUser = (userId, time, reason, _dir) => {
}

/**
* Check user AFK.
* @param {String} userId
* @param {Object} _dir
* @returns {Boolean}
* Check if user is on AFK state.
* @param {string} userId
* @param {object} _dir
* @returns {boolean}
*/
const checkAfkUser = (userId, _dir) => {
let status = false
Expand All @@ -30,10 +30,10 @@ const checkAfkUser = (userId, _dir) => {
}

/**
* Get AFK reason.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
* Get user AFK reason.
* @param {string} userId
* @param {object} _dir
* @returns {string}
*/
const getAfkReason = (userId, _dir) => {
let position = null
Expand All @@ -48,10 +48,10 @@ const getAfkReason = (userId, _dir) => {
}

/**
* Get AFK time.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
* Get user AFK time.
* @param {string} userId
* @param {object} _dir
* @returns {string}
*/
const getAfkTime = (userId, _dir) => {
let position = null
Expand All @@ -66,10 +66,10 @@ const getAfkTime = (userId, _dir) => {
}

/**
* Get AFK ID.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
* Get user AFK ID.
* @param {string} userId
* @param {object} _dir
* @returns {string}
*/
const getAfkId = (userId, _dir) => {
let position = null
Expand All @@ -84,10 +84,10 @@ const getAfkId = (userId, _dir) => {
}

/**
* Get AFK position.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
* Get user AFK index position.
* @param {string} userId
* @param {object} _dir
* @returns {number}
*/
const getAfkPosition = (userId, _dir) => {
let position = null
Expand Down
16 changes: 8 additions & 8 deletions function/daily.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fs = require('fs-extra')

/**
* Add limit.
* @param {String} userId
* @param {String} dir
* @param {Object} _dir
* Add user daily limit.
* @param {string} userId
* @param {string} dir
* @param {object} _dir
*/
const addLimit = (userId, _dir) => {
const obj = { id: userId, time: Date.now() }
Expand All @@ -13,10 +13,10 @@ const addLimit = (userId, _dir) => {
}

/**
* Get time limit.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
* Get user time left.
* @param {string} userId
* @param {object} _dir
* @returns {number}
*/
const getLimit = (userId, _dir) => {
let position = null
Expand Down
45 changes: 27 additions & 18 deletions function/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const fs = require('fs-extra')

/**
* Get user ID from db.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
* @param {string} userId
* @param {object} _dir
* @returns {string}
*/
const getLevelingId = (userId, _dir) => {
let pos = null
Expand All @@ -27,9 +27,9 @@ const getLevelingId = (userId, _dir) => {

/**
* Get user level from db.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
* @param {string} userId
* @param {object} _dir
* @returns {number}
*/
const getLevelingLevel = (userId, _dir) => {
let pos = null
Expand All @@ -52,9 +52,9 @@ const getLevelingLevel = (userId, _dir) => {

/**
* Get user XP from db.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
* @param {string} userId
* @param {object} _dir
* @returns {number}
*/
const getLevelingXp = (userId, _dir) => {
let pos = null
Expand All @@ -77,9 +77,9 @@ const getLevelingXp = (userId, _dir) => {

/**
* Add user level to db.
* @param {String} userId
* @param {Number} amount
* @param {Object} _dir
* @param {string} userId
* @param {number} amount
* @param {object} _dir
*/
const addLevelingLevel = (userId, amount, _dir) => {
let position = null
Expand All @@ -96,9 +96,9 @@ const addLevelingLevel = (userId, amount, _dir) => {

/**
* Add user XP to db.
* @param {String} userId
* @param {Number} amount
* @param {Object} _dir
* @param {string} userId
* @param {number} amount
* @param {object} _dir
*/
const addLevelingXp = (userId, amount, _dir) => {
let position = null
Expand All @@ -115,9 +115,9 @@ const addLevelingXp = (userId, amount, _dir) => {

/**
* Get user rank.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
* @param {string} userId
* @param {object} _dir
* @returns {number}
*/
const getUserRank = (userId, _dir) => {
let position = null
Expand All @@ -142,10 +142,19 @@ const getUserRank = (userId, _dir) => {
// Cooldown XP gains to prevent spam
const xpGain = new Set()

/**
* Check is user exist in set.
* @param {string} userId
* @returns {boolean}
*/
const isGained = (userId) => {
return !!xpGain.has(userId)
}

/**
* Add user in set and delete it when it's 1 minute.
* @param {string} userId
*/
const addCooldown = (userId) => {
xpGain.add(userId)
setTimeout(() => {
Expand Down
29 changes: 14 additions & 15 deletions function/limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const fs = require('fs-extra')

/**
* Check limit.
* @param {String} userId
* @param {Object} _dir
* @param {Number} limitCount
* @param {Boolean} isPremium
* @param {Boolean} isOwner
* @returns {Boolean}
* @param {string} userId
* @param {object} _dir
* @param {number} limitCount
* @param {boolean} isPremium
* @param {boolean} isOwner
* @returns {boolean}
*/
const isLimit = (userId, _dir, limitCount, isPremium, isOwner) => {
if (isPremium || isOwner) return false
Expand All @@ -33,11 +33,10 @@ const isLimit = (userId, _dir, limitCount, isPremium, isOwner) => {

/**
* Add limit to user.
* @param {String} userId
* @param {Object} _dir
* @param {Boolean} isPremium
* @param {Boolean} isOwner
* @returns {*}
* @param {string} userId
* @param {object} _dir
* @param {boolean} isPremium
* @param {boolean} isOwner
*/
const addLimit = (userId, _dir, isPremium, isOwner) => {
if (isPremium || isOwner) return false
Expand All @@ -55,10 +54,10 @@ const addLimit = (userId, _dir, isPremium, isOwner) => {

/**
* Get user's limit.
* @param {String} userId
* @param {Object} _dir
* @param {Number} limitCount
* @returns {Number}
* @param {string} userId
* @param {object} _dir
* @param {number} limitCount
* @returns {number}
*/
const getLimit = (userId, _dir, limitCount) => {
let pos = null
Expand Down
4 changes: 2 additions & 2 deletions function/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const { color } = require('../tools')
/**
* Returns an array of files.
* @param {*} dirPath
* @param {String[]} arrayOfFiles
* @returns {String[]}
* @param {string[]} [arrayOfFiles]
* @returns {string[]}
*/
const getAllDirFiles = (dirPath, arrayOfFiles) => {
const files = fs.readdirSync(dirPath)
Expand Down
34 changes: 17 additions & 17 deletions function/premium.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const toMs = require('ms')

/**
* Add premium user.
* @param {String} userId
* @param {String} expired
* @param {Object} _dir
* @param {string} userId
* @param {string} expired
* @param {object} _dir
*/
const addPremiumUser = (userId, expired, _dir) => {
const obj = { id: userId, expired: Date.now() + toMs(expired) }
Expand All @@ -14,9 +14,9 @@ const addPremiumUser = (userId, expired, _dir) => {
}

/**
* Get premium user position.
* @param {String} userId
* @param {Object} _dir
* Get premium user index position.
* @param {string} userId
* @param {object} _dir
* @returns {Number}
*/
const getPremiumPosition = (userId, _dir) => {
Expand All @@ -32,9 +32,9 @@ const getPremiumPosition = (userId, _dir) => {
}

/**
* Get premium user expire.
* @param {String} userId
* @param {Object} _dir
* Get premium user expired.
* @param {string} userId
* @param {object} _dir
* @returns {Number}
*/
const getPremiumExpired = (userId, _dir) => {
Expand All @@ -50,10 +50,10 @@ const getPremiumExpired = (userId, _dir) => {
}

/**
* Check user is premium.
* @param {String} userId
* @param {Object} _dir
* @returns {Boolean}
* Check if is user premium.
* @param {string} userId
* @param {object} _dir
* @returns {boolean}
*/
const checkPremiumUser = (userId, _dir) => {
let status = false
Expand All @@ -67,7 +67,7 @@ const checkPremiumUser = (userId, _dir) => {

/**
* Constantly checking premium.
* @param {Object} _dir
* @param {object} _dir
*/
const expiredCheck = (_dir) => {
setInterval(() => {
Expand All @@ -78,7 +78,7 @@ const expiredCheck = (_dir) => {
}
})
if (position !== null) {
console.log(`Premium expired: ${_dir[position].id}`)
console.log(`Premium user expired: ${_dir[position].id}`)
_dir.splice(position, 1)
fs.writeFileSync('./database/bot/premium.json', JSON.stringify(_dir))
}
Expand All @@ -87,8 +87,8 @@ const expiredCheck = (_dir) => {

/**
* Get all premium user ID.
* @param {Object} _dir
* @returns {String[]}
* @param {object} _dir
* @returns {string[]}
*/
const getAllPremiumUser = (_dir) => {
const array = []
Expand Down
Loading

0 comments on commit fab2ec3

Please sign in to comment.