This commit is contained in:
*x1
2024-06-21 16:42:04 +02:00
8 changed files with 264 additions and 19 deletions
+1
View File
@@ -2,6 +2,7 @@
db.sqlite
# Logs
logs/*
logs
*.log
npm-debug.log*
+29
View File
@@ -0,0 +1,29 @@
const { EmbedBuilder } = require('discord.js');
const db = require('../../fonctions/database.js');
const embedColor = require('../../fonctions/embedColor.js');
module.exports = {
aliases: ['perm', 'permission', 'permissions'],
description: 'Affiche les permission des rôles pour utiliser les commandes du bot.',
emote: '⏱️',
utilisation: '',
permission: 10,
async execute(message, args, client) {
const perms = await new Promise((resolve, reject) => {
db.all(`SELECT * FROM rolePermission WHERE guildId = ?`, [message.guild.id], (err, rows) => {
if (err) reject(err);
resolve(rows);
});
});
const embed = new EmbedBuilder()
.setTitle('⏱️ Permissions')
.setDescription(perms.map(perm => `**<@&${perm.roleId}>** : ${perm.permission}`).join('\n'))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
},
};
+77
View File
@@ -0,0 +1,77 @@
const { EmbedBuilder } = require('discord.js');
const db = require('../../fonctions/database.js');
const embedColor = require('../../fonctions/embedColor.js');
module.exports = {
aliases: ['setperm'],
description: 'Ajoute les permissions d\'un rôle pour utiliser les commandes du bot.',
emote: '⏱️',
utilisation: '<@role|None> <1|2|3|4|5>',
permission: 10,
async execute(message, args, client) {
if (!args[0] || !args[1]) {
const embed = new EmbedBuilder()
.setTitle('⏱️ Ajout de permissions')
.setDescription(`Vous devez spécifier un rôle et un niveau de permission.\n\n**Utilisation:** \`&setRolePerm <@role|None> <1|2|3|4|5>\``)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
let role;
if (args[0] === 'None') {
role = 'None';
} else {
role = message.mentions.roles.first().id;
}
if (isNaN(parseInt(args[1]))) {
const embed = new EmbedBuilder()
.setTitle('⏱️ Ajout de permissions')
.setDescription('Le deuxième argument doit être un nombre.')
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
if (args[1] < 1 || args[1] > 5) {
const embed = new EmbedBuilder()
.setTitle('⏱️ Ajout de permissions')
.setDescription('Le niveau de permission doit être compris entre 1 et 5.')
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
if (role === 'None') {
db.run(`DELETE FROM rolePermission WHERE guildId = ? AND permission = ?`, [message.guild.id, args[1]]);
const embed = new EmbedBuilder()
.setTitle('⏱️ Ajout de permissions')
.setDescription(`Les permissions de niveau ${args[1]} ont été retirées.`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
db.run(`INSERT OR REPLACE INTO rolePermission (guildId, roleId, permission) VALUES (?, ?, ?)`, [message.guild.id, role, args[1]]);
const embed = new EmbedBuilder()
.setTitle('⏱️ Ajout de permissions')
.setDescription(`Le rôle <@&${role}> a maintenant la permission de niveau ${args[1]}.`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
},
};
+2 -16
View File
@@ -1,8 +1,8 @@
const { Message, Events } = require("discord.js");
const db = require('../fonctions/database.js');
//const getPermissionLevel = require("../fonctions/getPermissionLevel");
var loggT = require('../loggerT.js');
var loggE = require('../loggerE.js');
const getPermissionLevel = require("../fonctions/getPermissionLevel.js");
module.exports = {
name: Events.MessageCreate,
@@ -33,24 +33,10 @@ module.exports = {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift()?.toLowerCase();
const command = client.commands.get(commandName);
if (!command) return;
const permissionLevel = 1 //await getPermissionLevel(message.member, message.guild);
const permissionLevel = await getPermissionLevel(message.guild.id, message.member);
if ((permissionLevel < command.permission) && (!client.config.owners.includes(message.author.id))) {
return message.reply("Vous n'avez pas la permission d'utiliser cette commande.");
}
try {
command.execute(message, args, client);
console.log(`[${prefix}}] ${message.guild.name} | ${message.author.tag} | ${command.name}`.blue)
loggT(`[${prefix}] ${message.guild.name} | ${message.author.tag} | ${command.name}`)
} catch (error) {
console.error(error);
loggE(error)
message.reply("Erreur lors de l'exécution de la commande");
}
}
}
if (message.content === `<@!${client.user.id}>` || message.content === `<@${client.user.id}>`) {
message.reply(`Mon prefix est \`${prefix}\``);
+7
View File
@@ -77,4 +77,11 @@ db.run(`CREATE TABLE IF NOT EXISTS alliances (
PRIMARY KEY (guildId, id)
)`);
db.run(`CREATE TABLE IF NOT EXISTS rolePermission (
guildId TEXT,
roleId TEXT,
permission INTEGER,
PRIMARY KEY (guildId, permission)
)`);
module.exports = db;
+15
View File
@@ -0,0 +1,15 @@
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;
}
+124
View File
@@ -2,3 +2,127 @@
[ERROR] || 20/051/2024 =>> 18h 37m 19s 551ms || TypeError: team.forEach is not a function
[ERROR] || 20/051/2024 =>> 18h 37m 19s 628ms || TypeError: team.forEach is not a function
[ERROR] || 20/051/2024 =>> 18h 37m 19s 661ms || TypeError: team.forEach is not a function
[ERROR] || 21/051/2024 =>> 16h 19m 08s 453ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 08s 515ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 08s 640ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 08s 915ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 109ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 160ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 223ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 292ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 432ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 544ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 655ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 867ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 09s 928ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 007ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 064ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 159ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 187ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 312ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 413ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 502ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 546ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 637ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 753ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 853ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 911ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 10s 990ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 045ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 067ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 097ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 168ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 202ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 307ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 335ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 368ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 443ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 483ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 542ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 605ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 698ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 808ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 891ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 967ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 11s 986ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 012ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 077ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 143ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 218ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 308ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 356ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 436ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 508ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 638ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 771ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 822ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 941ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 12s 990ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 058ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 243ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 492ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 549ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 605ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 662ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 689ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 763ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 801ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 872ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 13s 942ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 14s 063ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 14s 426ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 14s 656ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 14s 807ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 14s 859ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 14s 984ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 136ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 225ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 358ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 421ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 472ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 557ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 581ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 664ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 726ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 765ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 823ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 886ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 936ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 15s 990ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 19m 16s 070ms || Error: SQLITE_ERROR: table users has no column named guildName
[ERROR] || 21/051/2024 =>> 16h 20m 08s 190ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 20m 08s 193ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 20m 08s 454ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 20m 08s 459ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 21m 08s 190ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 21m 08s 195ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 21m 08s 502ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 21m 08s 534ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 22m 08s 202ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 22m 08s 204ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 22m 08s 466ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 22m 08s 470ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 23m 08s 204ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 23m 08s 211ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 23m 08s 489ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 23m 08s 744ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 24m 08s 218ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 24m 08s 222ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 24m 08s 484ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 24m 08s 487ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 25m 08s 232ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 25m 08s 234ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 25m 08s 496ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 25m 08s 500ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 26m 08s 236ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 26m 08s 239ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 26m 08s 504ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 26m 08s 507ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 27m 08s 239ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 27m 08s 241ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 27m 08s 507ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 27m 08s 509ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 28m 08s 244ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 28m 08s 265ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 28m 08s 513ms || ReferenceError: message is not defined
[ERROR] || 21/051/2024 =>> 16h 28m 08s 516ms || ReferenceError: message is not defined
+6
View File
@@ -24,3 +24,9 @@
[TEXT] || 21/05/2024 =>> 07h 17m 26s 194ms || [READY] Coins#9235 est prêt ||| 4 serveurs | 479 utilisateurs
[TEXT] || 21/05/2024 =>> 07h 17m 26s 280ms || [READY] Coins#9235 est prêt ||| 4 serveurs | 479 utilisateurs
[TEXT] || 21/05/2024 =>> 16h 19m 06s 369ms || 5 events loaded
[TEXT] || 21/05/2024 =>> 16h 19m 06s 630ms || 65 commands loaded
[TEXT] || 21/05/2024 =>> 16h 19m 08s 140ms || [READY] Azelie Coins#3640 est prêt ||| 1 serveurs | 11 utilisateurs
[TEXT] || 21/05/2024 =>> 16h 19m 08s 179ms || [READY] Azelie Coins#3640 est prêt ||| 1 serveurs | 11 utilisateurs