mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
const db = require('quick.db');
|
|
const GestionDb = new db.table('gestion')
|
|
|
|
async function getPermissionLevel(member, client) {
|
|
const botId = client.user.id;
|
|
const buyerId = ['1003985920162287696', '671763971803447298'];
|
|
let owners = await GestionDb.get(`${botId}.owners`) || {};
|
|
if (buyerId.includes(member.id)) {
|
|
return 11;
|
|
}
|
|
if (owners[member.id]) {
|
|
return 10;
|
|
}
|
|
let highestPermission = 0;
|
|
try {
|
|
for (let i = 1; i <= 9; i++) {
|
|
const roleIds = await GestionDb.get(`${botId}.${member.guild.id}.p${i}`);
|
|
if (roleIds) {
|
|
if (!Array.isArray(roleIds)) {
|
|
roleIds = [roleIds];
|
|
}
|
|
if (roleIds.some(id => member.roles.cache.has(id))) {
|
|
highestPermission = Math.max(highestPermission, i);
|
|
}
|
|
}
|
|
}
|
|
return highestPermission;
|
|
} catch {
|
|
return highestPermission;
|
|
}
|
|
}
|
|
module.exports = { getPermissionLevel }; |