mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-02 23:25:20 +00:00
Add isMaster util function
This commit is contained in:
20
utils/config.js
Normal file
20
utils/config.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('../config');
|
||||
const eq = require('./eq');
|
||||
|
||||
const masterById = /^\d+$/.test(config.master);
|
||||
const masterByUsername = /^@?\w+$/.test(config.master);
|
||||
|
||||
if (!masterById && !masterByUsername) {
|
||||
throw new Error('Invalid value for `master` in config file: ' +
|
||||
config.master);
|
||||
}
|
||||
|
||||
const isMaster = masterById
|
||||
? user => user.id === Number(config.master)
|
||||
: user => user.username && eq.username(user.username, config.master);
|
||||
|
||||
module.exports = {
|
||||
isMaster,
|
||||
};
|
Reference in New Issue
Block a user