Added function to check perms(web)

This commit is contained in:
filipnyquist 2018-05-20 21:13:30 +02:00
parent 7712d9f954
commit 6588aaf41f
2 changed files with 9 additions and 2 deletions

View file

@ -18,7 +18,7 @@
"comma-dangle": ["off"],
"import/extensions": 0,
"guard-for-in": ["warn"],
"no-restricted-syntax": ["warn"],
"no-restricted-syntax": ["off"],
"object-curly-spacing": ["off"],
"padded-blocks": ["off"],
"no-underscore-dangle": [

View file

@ -1,4 +1,4 @@
// import Discord from "discord.js";
import Discord from "discord.js";
import express from "express";
import session from "express-session";
import passport from "passport";
@ -34,6 +34,13 @@ function checkAuth(req, res, next) {
if (req.isAuthenticated()) return next();
res.send("not logged in :(");
}
// Returns all the guilds a user can control
function canControlGuilds(guilds) {
return guilds.filter(g => {
gp = new Discord.Permissions(null, g.permissions);
return gp.has("MANAGE_GUILD");
});
}
// Lets get some sessions going!
app.use(
session({