mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 23:36:29 +02:00
15 lines
542 B
JavaScript
15 lines
542 B
JavaScript
const db = require('./database.js');
|
|
|
|
module.exports = async function getPermissionLevel(serverId, user) {
|
|
const roles = user.roles.cache.map(role => role.id);
|
|
|
|
const perms = await new Promise((resolve, reject) => {
|
|
db.all(`SELECT * FROM rolePermission WHERE guildId = ? AND roleId IN (${roles.map(() => '?').join(',')})`, [serverId, ...roles], (err, rows) => {
|
|
if (err) reject(err);
|
|
resolve(rows);
|
|
});
|
|
});
|
|
|
|
const highestPermission = Math.max(...perms.map(perm => perm.permission));
|
|
return highestPermission;
|
|
} |