mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-21 13:54:50 +02:00
52 lines
2.8 KiB
JavaScript
52 lines
2.8 KiB
JavaScript
const { EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } = require('discord.js');
|
|
const db = require('../../fonctions/database.js');
|
|
const embedColor = require('../../fonctions/embedColor.js');
|
|
|
|
module.exports = {
|
|
aliases: ['leaderboard', 'lb'],
|
|
description: 'Affiche le top 10 des membres du serveur',
|
|
emote: '🏆',
|
|
utilisation: '[coins|pocket|bank|reputation|niveau]',
|
|
permission: 0,
|
|
|
|
async execute(message, args, client) {
|
|
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') {
|
|
args[0] = 'pocket'
|
|
} else if (args[0] === 'bank' || args[0] === 'banque' || args[0] === 'coffre' || args[0] === 'coffre-fort' || args[0] === 'bk') {
|
|
args[0] = 'bank'
|
|
} else if (args[0] === 'reputation' || args[0] === 'rep' || args[0] === 'réputation' || args[0] === 'reput') {
|
|
args[0] = 'reputation'
|
|
} else if (args[0] === 'niveau' || args[0] === 'lvl' || args[0] === 'level' || args[0] === 'lvl') {
|
|
args[0] = 'niveau'
|
|
} else if (!args[0]) {
|
|
args[0] = 'coins'
|
|
} else {
|
|
args[0] = 'coins'
|
|
message.reply({ embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle('Argument invalide')
|
|
.setDescription(`Vous pouvez utiliser les arguments suivants: \`coins\`, \`pocket\`, \`bank\`, \`reputation\`, \`niveau\` ou ne rien mettre pour afficher le top 10 des membres du serveur.`)
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() })
|
|
], allowedMentions: { repliedUser: false } })
|
|
}
|
|
|
|
let data;
|
|
if (args[0] === 'coins') {
|
|
data = db.all(`SELECT userId, pocket+bank AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10`, [message.guild.id]);
|
|
} else if (args[0] === 'pocket') {
|
|
data = db.all(message.guild.id, 'SELECT userId, pocket AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10', [message.guild.id]);
|
|
} else if (args[0] === 'bank') {
|
|
data = db.all(message.guild.id, 'SELECT userId, bank AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10', [message.guild.id]);
|
|
} else if (args[0] === 'reputation') {
|
|
data = db.all(message.guild.id, 'SELECT userId, reputation AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10', [message.guild.id]);
|
|
} else if (args[0] === 'niveau') {
|
|
data = db.all(message.guild.id, 'SELECT userId, lvl AS coins FROM users WHERE guildId = ? ORDER BY coins DESC LIMIT 10', [message.guild.id]);
|
|
}
|
|
|
|
console.log(data)
|
|
},
|
|
} |