From 233f25d0f32d5de9afb1341a9e88b38ad3e0432c Mon Sep 17 00:00:00 2001 From: *x1 Date: Mon, 8 Jul 2024 21:21:38 +0200 Subject: [PATCH] Update global --- commands/bot control/blacklistAdd.js | 2 +- commands/bot control/blacklistRemove.js | 2 +- commands/casino/me.js | 25 ++++++++++-- commands/casino/rob.js | 2 +- commands/casino/sell.js | 2 +- commands/casino/top.js | 30 +++++++++++++- commands/gestion/setRolePerm.js | 2 +- commands/jobs/hack.js | 52 +++---------------------- commands/teams admin/tedit.js | 28 +++++++------ commands/teams/tcadenas.js | 19 ++++++++- commands/teams/tdeposit.js | 13 ++----- commands/teams/trep.js | 32 ++++----------- events/messageCreate.js | 10 +++-- events/messageCreateLVL.js | 2 +- events/ready.js | 15 +++++-- 15 files changed, 124 insertions(+), 112 deletions(-) diff --git a/commands/bot control/blacklistAdd.js b/commands/bot control/blacklistAdd.js index ae38b63..b292d39 100644 --- a/commands/bot control/blacklistAdd.js +++ b/commands/bot control/blacklistAdd.js @@ -29,7 +29,7 @@ module.exports = { } db.run( - `UPDATE users SET blacklist = true WHERE guildId = ? AND userId = ?`, + `UPDATE users SET blacklist = 1 WHERE guildId = ? AND userId = ?`, [message.guild.id, member.id], ); diff --git a/commands/bot control/blacklistRemove.js b/commands/bot control/blacklistRemove.js index e42bfa2..526069d 100644 --- a/commands/bot control/blacklistRemove.js +++ b/commands/bot control/blacklistRemove.js @@ -29,7 +29,7 @@ module.exports = { } db.run( - `UPDATE users SET blacklist = false WHERE guildId = ? AND userId = ?`, + `UPDATE users SET blacklist = 0 WHERE guildId = ? AND userId = ?`, [message.guild.id, member.id], ); diff --git a/commands/casino/me.js b/commands/casino/me.js index f3eee27..7c62f2e 100644 --- a/commands/casino/me.js +++ b/commands/casino/me.js @@ -34,12 +34,29 @@ module.exports = { }, ); }); - const pocket = Math.round(user.pocket); - const bank = Math.round(user.bank); + function convert(labelValue) { + + return Math.abs(Number(labelValue)) >= 1.0e+9 + + ? (Math.abs(Number(labelValue)) / 1.0e+9).toFixed(2) + "B" + + : Math.abs(Number(labelValue)) >= 1.0e+6 + + ? (Math.abs(Number(labelValue)) / 1.0e+6).toFixed(2) + "M" + + : Math.abs(Number(labelValue)) >= 1.0e+3 + + ? (Math.abs(Number(labelValue)) / 1.0e+3).toFixed(2) + "K" + + : Math.abs(Number(labelValue)); + + } + const pocket = convert(Math.round(user.pocket)); + const bank = convert(Math.round(user.bank)); const reputation = user.reputation; const niveau = user.lvl; - const xp = user.xp; - const tdrop = Math.round(user.tdroper); + const xp = convert(user.xp); + const tdrop = convert(Math.round(user.teamDroper)); let anti_rob = ``; if (user.antiRob + 7200000 > Date.now()) { diff --git a/commands/casino/rob.js b/commands/casino/rob.js index fba30db..8497a31 100644 --- a/commands/casino/rob.js +++ b/commands/casino/rob.js @@ -93,7 +93,7 @@ module.exports = { ); }); - if (memberInfo.antiRob + 7200000 > Date.now()) { + if ((memberInfo.antiRob + 7200000) > Date.now()) { const embed = new EmbedBuilder() .setTitle("Erreur") .setDescription( diff --git a/commands/casino/sell.js b/commands/casino/sell.js index d696603..a25b211 100644 --- a/commands/casino/sell.js +++ b/commands/casino/sell.js @@ -112,7 +112,7 @@ module.exports = { if (!interaction.isSelectMenu()) return; if (!interaction.customId === "sell") return; - const selected = interaction.values[0]; + const selected = interaction.values; if (selected === "1") { if (user.objet < 1) { diff --git a/commands/casino/top.js b/commands/casino/top.js index 0def4b8..117973e 100644 --- a/commands/casino/top.js +++ b/commands/casino/top.js @@ -187,6 +187,24 @@ module.exports = { }); } + function convert(labelValue) { + + return Math.abs(Number(labelValue)) >= 1.0e+9 + + ? (Math.abs(Number(labelValue)) / 1.0e+9).toFixed(2) + "B" + + : Math.abs(Number(labelValue)) >= 1.0e+6 + + ? (Math.abs(Number(labelValue)) / 1.0e+6).toFixed(2) + "M" + + : Math.abs(Number(labelValue)) >= 1.0e+3 + + ? (Math.abs(Number(labelValue)) / 1.0e+3).toFixed(2) + "K" + + : Math.abs(Number(labelValue)); + + } + const emoji = { coins: "🪙", pocket: "💰", @@ -200,6 +218,16 @@ module.exports = { let leaderboard = data .map((row, i) => { + const user = { + coins: '<@' + row.userId + '>', + pocket: '<@' + row.userId + '>', + bank: '<@' + row.userId + '>', + reputation: '<@' + row.userId + '>', + niveau: '<@' + row.userId + '>', + team: row.name, + teamreputation: row.name, + teamdroper: '<@' + row.userId + '>' + } let position; switch (i) { case 0: @@ -214,7 +242,7 @@ module.exports = { default: position = `**${i + 1}.**`; } - return `${position} <@${row.userId}> - \`${row.coins}\` ${emoji[type]}`; + return `${position} ${user[type]} - \`${convert(row.coins)}\` ${emoji[type]}`; }) .join("\n\n"); diff --git a/commands/gestion/setRolePerm.js b/commands/gestion/setRolePerm.js index c5b46f8..03df8dd 100644 --- a/commands/gestion/setRolePerm.js +++ b/commands/gestion/setRolePerm.js @@ -34,7 +34,7 @@ module.exports = { if (args[0] === "None") { role = "None"; } else { - role = message.mentions.roles.first().id; + role = message.mentions.roles.first()?.id; } if (isNaN(parseInt(args[1]))) { diff --git a/commands/jobs/hack.js b/commands/jobs/hack.js index 0fbeca3..ed4e0d4 100644 --- a/commands/jobs/hack.js +++ b/commands/jobs/hack.js @@ -93,7 +93,7 @@ module.exports = { const embed = new EmbedBuilder() .setTitle("Hack Impossible") .setDescription( - `❌ Vous avez déjà hack une team récemment. Veuillez attendre ${Math.floor((lastHack + 7200000 - Date.now()) / 60000)} minutes avant de pouvoir ajouter une reputation à nouveau.`, + `❌ Vous avez déjà hack une team récemment. Veuillez attendre ${Math.floor((lastHack + 7200000 - Date.now()) / 60000)} minutes avant de pouvoir hacker à nouveau.`, ) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() @@ -150,57 +150,15 @@ module.exports = { text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL(), }); - - if (team.padlock == 1) { - db.run( - `UPDATE users SET bank =? WHERE guildId =? AND userId =?`, - [user.bank + team.bank, message.guild.id, message.author.id], - (err) => { - if (err) { - console.log(`${err}`.red); - } - }, - ); - db.run( - `UPDATE teams SET bank = 0 WHERE guildId =? AND userId =?`, - [message.guild.id, message.author.id], - (err) => { - if (err) { - console.log(`${err}`.red); - } - }, - ); - - const embed2 = new EmbedBuilder() - .setTitle("Vole de la banque !") - .setDescription("Vous n'avez pas reussi à casser un cadenas de la team `" + team.name + "`, qui à donc, toujours, `" + team.padlock + "` cadenas.") - .setColor(await embedColor(message.author.id, message.guild.id)) - .setTimestamp() - .setImage("") - .setFooter({ - text: `Demandé par ${message.author.tag}`, - iconURL: message.author.displayAvatarURL(), - }); - - message.reply({ - embeds: [embed, embed2], - allowedMentions: { repliedUser: false }, - }); - } else { - message.reply({ - embeds: [embed], - allowedMentions: { repliedUser: false }, - }); - } } else { const embed = new EmbedBuilder() .setTitle("Erreur lors du hack !") .setDescription( "Vous n'avez pas reussi à casser un cadenas de la team `" + - team.name + - "`, qui à donc, toujours, `" + - team.padlock + - "` cadenas.", + team.name + + "`, qui à donc, toujours, `" + + team.padlock + + "` cadenas.", ) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() diff --git a/commands/teams admin/tedit.js b/commands/teams admin/tedit.js index 41bed49..ae88536 100644 --- a/commands/teams admin/tedit.js +++ b/commands/teams admin/tedit.js @@ -12,17 +12,21 @@ module.exports = { async execute(message, args, client) { if (args.length > 0) { let subCommand = args[0].toLowerCase(); - subCommand = subCommand.replice("n", "name"); - subCommand = subCommand.replice("nom", "name"); - subCommand = subCommand.replice("noms", "name"); - subCommand = subCommand.replice("banniere", "banner"); - subCommand = subCommand.replice("bannière", "banner"); - subCommand = subCommand.replice("b", "banner"); - subCommand = subCommand.replice("i", "icon"); - subCommand = subCommand.replice("p", "icon"); - subCommand = subCommand.replice("photo", "icon"); - subCommand = subCommand.replice("icone", "icon"); - subCommand = subCommand.replice("d", "description"); + if (!["name", "banner", "icon", "description"].includes(subCommand)) { + subCommand = subCommand.replace("nom", "name"); + subCommand = subCommand.replace("banniere", "banner"); + subCommand = subCommand.replace("bannière", "banner"); + subCommand = subCommand.replace("photo", "icon"); + subCommand = subCommand.replace("icone", "icon"); + if (!["name", "banner", "icon", "description"].includes(subCommand)) { + subCommand = subCommand.replace("d", "description"); + subCommand = subCommand.replace("n", "name"); + subCommand = subCommand.replace("i", "icon"); + subCommand = subCommand.replace("p", "icon"); + subCommand = subCommand.replace("b", "banner"); + } + } + const newValue = args.slice(1).join(" "); @@ -56,7 +60,7 @@ module.exports = { const embed = new EmbedBuilder() .setTitle("🖋️ Modification de team") .setDescription( - "❌ Vous devez spécifier ce que vous voulez modifier (name, banner, icon ou description).", + "❌ Vous devez spécifier ce que vous voulez modifier (nom, banner, icon ou description).", ) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() diff --git a/commands/teams/tcadenas.js b/commands/teams/tcadenas.js index cc61e6a..1de13d3 100644 --- a/commands/teams/tcadenas.js +++ b/commands/teams/tcadenas.js @@ -6,11 +6,26 @@ module.exports = { aliases: ["tcadena"], description: "Ajoute un cadenas à une team. (max : 5, coût : 3reputation)", emote: "🔒", - utilisation: "", + utilisation: "[team-id]", permission: 0, async execute(message, args, client) { - const teamID = args[0] + const user = await new Promise((resolve, reject) => { + db.get( + `SELECT * FROM users WHERE guildId = ? AND userId = ?`, + [message.guild.id, message.author.id], + (err, row) => { + if (err) reject(err); + resolve(row); + }, + ); + }); + let teamID; + if (args) { + teamID = args[0] + } else ( + teamID = user.teamId + ) const team = await new Promise((resolve, reject) => { db.get( `SELECT * FROM teams WHERE guildId = ? AND id = ?`, diff --git a/commands/teams/tdeposit.js b/commands/teams/tdeposit.js index 898d2c0..0bd595b 100644 --- a/commands/teams/tdeposit.js +++ b/commands/teams/tdeposit.js @@ -96,8 +96,8 @@ module.exports = { const team = await new Promise((resolve, reject) => { db.get( - `SELECT * FROM users WHERE guildId = ? AND userId = ?`, - [message.guild.id, message.author.id], + `SELECT * FROM teams WHERE guildId = ? AND id = (SELECT teamId FROM users WHERE guildId = ? AND userId = ?)`, + [message.guild.id, message.guild.id, message.author.id], (err, row) => { if (err) reject(err); resolve(row); @@ -120,13 +120,8 @@ module.exports = { allowedMentions: { repliedUser: false }, }); } else { - db.run( - `UPDATE users SET pocket = pocket - ?, teamDroper = teamDroper + ? WHERE guildId = ? AND userId = ?`, - [amout, amout, message.guild.id, message.author.id], - ); - db.run(`UPDATE teams SET bank = bank + ? WHERE guildId = ? AND id = ?`, - [ amout, message.guild.id, team.id ] - ); + db.run(`UPDATE users SET pocket = pocket - ?, teamDroper = teamDroper + ? WHERE guildId = ? AND userId = ?`, [amout, amout, message.guild.id, message.author.id]); + db.run(`UPDATE teams SET bank = bank + ? WHERE guildId = ? AND id = ?`, [amout, message.guild.id, team.id]); const embed = new EmbedBuilder() .setTitle("Dépôt Effectué") diff --git a/commands/teams/trep.js b/commands/teams/trep.js index 079a8a4..2c91579 100644 --- a/commands/teams/trep.js +++ b/commands/teams/trep.js @@ -10,24 +10,6 @@ module.exports = { permission: 0, async execute(message, args, client) { - if (!args[0]) { - const embed = new EmbedBuilder() - .setTitle("Ajout Impossible") - .setDescription(`❌ Veuillez indiquer l'id une team.`) - .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 }, - }); - } - const teamID = args[0].toLowerCase(); - const user = await new Promise((resolve, reject) => { db.get( `SELECT * FROM users WHERE guildId = ? AND userId = ?`, @@ -40,6 +22,13 @@ module.exports = { }); const lastTrep = user.lastTrep; + let teamID; + if (!args[0]) { + teamID = user.teamId + } else { + teamID = args[0].toLowerCase(); + } + const team = await new Promise((resolve, reject) => { db.get( `SELECT * FROM teams WHERE guildId = ? AND id = ?`, @@ -110,12 +99,7 @@ module.exports = { const embed = new EmbedBuilder() .setTitle("Reputation ajouté !") - .setDescription( - "Vous avez ajouter une reputation à la team `" + - team.name + - "`, qui a maintement `" + - (team.reputation + 1) + - "` reputation !", + .setDescription(await "Vous avez ajouter une reputation à la team `" + team.name + "`, qui a maintement `" + (team.reputation + 1) + "` reputation !", ) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() diff --git a/events/messageCreate.js b/events/messageCreate.js index d768242..2a10833 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -18,7 +18,7 @@ module.exports = { }, ); }); - if (user.blacklist == true) { + if (user.blacklist == 1) { return; } @@ -39,8 +39,10 @@ module.exports = { message.member, ); if ( - permissionLevel < command.permission && - !client.config.owners.includes(message.author.id) + (permissionLevel <= command.permission) && + (client.config.owners.includes(!message.author.id) /*|| + (!message.guild.ownerId == message.author.id)*/ + ) ) { return message.reply( "Vous n'avez pas la permission d'utiliser cette commande.", @@ -50,7 +52,7 @@ module.exports = { try { command.execute(message, args, client); console.log( - `[${prefix}}] ${message.guild.name} | ${message.author.tag} | ${command.name}` + `[${prefix}] ${message.guild.name} | ${message.author.tag} | ${command.name}` .blue, ); loggT( diff --git a/events/messageCreateLVL.js b/events/messageCreateLVL.js index 6c50958..23fcc01 100644 --- a/events/messageCreateLVL.js +++ b/events/messageCreateLVL.js @@ -19,7 +19,7 @@ module.exports = { }, ); }); - if (user.blacklist == true) { + if (user.blacklist == 1) { return; } diff --git a/events/ready.js b/events/ready.js index 1f3fd9f..68bdf88 100644 --- a/events/ready.js +++ b/events/ready.js @@ -45,6 +45,7 @@ module.exports = { guild.members.cache .filter((member) => member.voice.channel) .forEach((member) => { + if (member.bot == true) return if (member.voice.selfMute == true) { db.run( "UPDATE users SET pocket = pocket + 50 WHERE guildId = ? AND userId = ?", @@ -68,6 +69,7 @@ module.exports = { guild.members.cache .filter((member) => member.voice.channel && member.voice.streaming) .forEach((member) => { + if (member.bot == true) return db.run( "UPDATE users SET pocket = pocket + 200 WHERE guildId = ? AND userId = ?", [guild.id, member.id], @@ -80,6 +82,7 @@ module.exports = { guild.members.cache .filter((member) => member.voice.channel && member.voice.selfVideo) .forEach((member) => { + if (member.bot == true) return db.run( "UPDATE users SET pocket = pocket + 200 WHERE guildId = ? AND userId = ?", [guild.id, member.id], @@ -93,7 +96,7 @@ module.exports = { }, 15 * 60 * 1000, ); - +/* setInterval( async () => { const team = await new Promise((resolve, reject) => { @@ -108,11 +111,13 @@ module.exports = { }, 1 * 60 * 1000, ); - +*/ //AntiCrash process.on("unhandledRejection", (error) => { if (error.code == "10064") return; + if (error.code == "10062") return; if (error.code == "10008") return; + if (error.code == "50007") return; console.log(" [antiCrash] :: Unhandled Rejection/Catch".red); console.log(`${error}`.grey); loggE(error); @@ -120,7 +125,8 @@ module.exports = { process.on("uncaughtException", (error, origin) => { if (error.code == "10064") return; - if (error.code == "10008") return; + if (error.code == "10008") return; + if (error.code == "10062") return; console.log(" [antiCrash] :: Uncaught Exception/Catch".red); console.log(`${error}`.grey); console.log("Information supplémentaire:", origin); @@ -129,6 +135,7 @@ module.exports = { process.on("uncaughtExceptionMonitor", (error, origin) => { if (error.code == "10064") return; + if (error.code == "10062") return; if (error.code == "10008") return; console.log(" [antiCrash] :: Uncaught Exception Monitor/Catch".red); console.log(`${error}`.grey); @@ -139,6 +146,7 @@ module.exports = { process.on("beforeExit", (code) => { if (error.code == "10064") return; if (error.code == "10008") return; + if (error.code == "10062") return; console.log(" [antiCrash] :: Before Exit".red); console.log("Code de sortie:", code); }); @@ -146,6 +154,7 @@ module.exports = { process.on("exit", (code) => { if (error.code == "10064") return; if (error.code == "10008") return; + if (error.code == "10062") return; console.log(" [antiCrash] :: Exit".red); console.log("Code de sortie:", code); });