mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-26 03:47:11 +00:00
21 lines
490 B
JavaScript
21 lines
490 B
JavaScript
|
'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,
|
||
|
};
|