diff --git a/commands/casino/top.js b/commands/casino/top.js index 5cb204e..fabc479 100644 --- a/commands/casino/top.js +++ b/commands/casino/top.js @@ -6,10 +6,11 @@ module.exports = { aliases: ['leaderboard', 'lb'], description: 'Affiche le top 10 des membres du serveur.', emote: '🏆', - utilisation: '[global|pocket|bank|reputation|niveau]', + utilisation: '[global|pocket|bank|reputation|niveau|teamdonnateur]', permission: 0, async execute(message, args, client) { + args[0] = args[0].toLowerCase() if (args[0] === 'coins' || args[0] === 'coin' || args[0] === 'global' || args[0] === 'money') { args[0] = 'coins' } else if (args[0] === 'pocket' || args[0] === 'cash' || args[0] === 'wallet' || args[0] === 'porte-monnaie' || args[0] === 'poche') { @@ -20,6 +21,8 @@ module.exports = { args[0] = 'reputation' } else if (args[0] === 'niveau' || args[0] === 'lvl' || args[0] === 'level' || args[0] === 'lvl') { args[0] = 'niveau' + } else if (args[0] === 'teamdonnateur' || args[0] === ' tdonnateur' || args[0] === 'tdroper' || args[0] === ' tdropper' || args[0] === ' teamdrop' || args[0] === 'tdrop' || args[0] === 'teamdroper' || args[0] === 'teamdropper') { + args[0] = 'teamdroper' } else if (!args[0]) { args[0] = 'coins' } else { @@ -71,6 +74,13 @@ module.exports = { resolve(rows); }); }); + } else if (type === 'teamdroper') { + data = await new Promise((resolve, reject) => { + db.all(`SELECT userId, teamdroper AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10`, [message.guild.id], (err, rows) => { + if (err) reject(err); + resolve(rows); + }); + }); } const emoji = { @@ -78,7 +88,8 @@ module.exports = { pocket: '💰', bank: '🏦', reputation: '🔺', - niveau: '📊' + niveau: '📊', + teamdroper: '🎁' } let leaderboard = data.map((row, i) => { @@ -139,7 +150,12 @@ module.exports = { .setLabel('Niveau') .setEmoji('📊') .setDescription('Affiche le top en fonction du niveau') - .setValue('niveau') + .setValue('niveau'), + new StringSelectMenuOptionBuilder() + .setLabel('TeamDroper') + .setEmoji('🎁') + .setDescription('Affiche le top en fonction du nombre de coins donnés à une team') + .setValue('teamdroper') ); const row = new ActionRowBuilder() diff --git a/commands/teams/team.js b/commands/teams/team.js index a60d910..2be77ff 100644 --- a/commands/teams/team.js +++ b/commands/teams/team.js @@ -51,9 +51,35 @@ module.exports = { CadenaS = "🔐" } + //////////////////////////////////////////////////// TEAM DROPER /////////////////////////////////////////////////////////////////// + data = await new Promise((resolve, reject) => { + db.all(`SELECT userId, teamDroper AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10`, [message.guild.id], (err, rows) => { + if (err) reject(err); + resolve(rows); + }); + }); + let leaderboard = data.map((row, i) => { + let position; + switch (i) { + case 0: + position = ':first_place:'; + break; + case 1: + position = ':second_place:'; + break; + case 2: + position = ':third_place:'; + break; + default: + position = `**${i + 1}.**`; + } + return `${position} <@${row.userId}> - \`${row.coins}\`coins donné(s)`; + }).join('\n'); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + const embed = new EmbedBuilder() .setTitle('🛡️ Informations de `' + team.name + '`:') - .setDescription(`**Id:** \`${team.id}\`\n**Description:** \`${team.description}\`\n**Banque:** \`${team.bank}\`coins\n**Niveau:** \`${team.level}\`\n**Reputation:** \`${team.reputation}\`\n\n**Soldats:** \`${team.soldiers}\`\n**Soldats blessés:** \`${team.woundedSoldiers}\`\n**Niveau du camp:** \`${team.campLevel}\`\n**Tourelles:** \`${team.turrets}\`\n**Cadenas:** \`${CadenaS}\`\n\n**Membres (\`${memberlist.length}\`):**\n${memberlist.map(member => `**${member.teamRole}:** <@${member.userId}>`).join('\n')}`) + .setDescription(`**Id:** \`${team.id}\`\n**Description:** \`${team.description}\`\n**Banque:** \`${team.bank}\`coins\n**Niveau:** \`${team.level}\`\n**Reputation:** \`${team.reputation}\`\n\n**Soldats:** \`${team.soldiers}\`\n**Soldats blessés:** \`${team.woundedSoldiers}\`\n**Niveau du camp:** \`${team.campLevel}\`\n**Tourelles:** \`${team.turrets}\`\n**Cadenas:** \`${CadenaS}\`\n\n**Membres (\`${memberlist.length}\`):**\n${memberlist.map(member => `**${member.teamRole}:** <@${member.userId}>`).join('\n')}\nLes 10 meilleurs donnateur de la team sont :\n\n${leaderboard}`) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });