mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
add fonction.js
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
const roleIds = await GestionDb.get(`${botId}.${member.guild.id}.p${i}`);
|
||||
if (roleIds) {
|
||||
// Si roleIds n'est pas un tableau, le convertir en tableau
|
||||
if (!Array.isArray(roleIds)) {
|
||||
roleIds = [roleIds];
|
||||
}
|
||||
if (roleIds.some(id => member.roles.cache.has(id))) {
|
||||
highestPermission = Math.max(highestPermission, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return highestPermission;
|
||||
}
|
||||
module.exports = { getPermissionLevel };
|
||||
Reference in New Issue
Block a user