mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-05 21:51:43 +02:00
73 lines
3.1 KiB
JavaScript
73 lines
3.1 KiB
JavaScript
const { EmbedBuilder } = require('discord.js');
|
|
const db = require('../../fonctions/database.js');
|
|
const embedColor = require('../../fonctions/embedColor.js');
|
|
|
|
module.exports = {
|
|
aliases: ['t', 'tinfo', 'teaminfo'],
|
|
description: 'Affiche les informations de votre team.',
|
|
emote: '🛡️',
|
|
utilisation: '',
|
|
permission: 0,
|
|
|
|
async execute(message, args, client) {
|
|
const team = await new Promise((resolve, reject) => {
|
|
db.get(`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);
|
|
});
|
|
});
|
|
|
|
if (!team) {
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('🛡️ Informations de team')
|
|
.setDescription('Vous n\'êtes actuellement pas dans 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 } });
|
|
} else {
|
|
const memberlist = await new Promise((resolve, reject) => {
|
|
db.all(`SELECT userId, teamRole FROM users WHERE guildId = ? AND teamId = ?`, [message.guild.id, team.id], (err, rows) => {
|
|
if (err) reject(err);
|
|
resolve(rows);
|
|
});
|
|
});
|
|
let CadenaS = ":unlock:"
|
|
if (team.padlock == 5) {
|
|
CadenaS = ":lock::lock::lock::lock::lock:"
|
|
}
|
|
if (team.padlock == 4) {
|
|
CadenaS = ":lock::lock::lock::lock:"
|
|
}
|
|
if (team.padlock == 3) {
|
|
CadenaS = ":lock::lock::lock:"
|
|
}
|
|
if (team.padlock == 2) {
|
|
CadenaS = ":lock::lock:"
|
|
}
|
|
if (team.padlock == 1) {
|
|
CadenaS = ":lock:"
|
|
}
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('🛡️ Informations de team')
|
|
.setDescription(`**Nom:** ${team.name}\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')}`)
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
|
|
|
|
const urlRegex1 = /(https?:\/\/[^\s]+)/g;
|
|
if (team.icon && urlRegex1.test(team.icon)) {
|
|
embed.setThumbnail(team.icon);
|
|
}
|
|
|
|
const urlRegex2 = /(https?:\/\/[^\s]+)/g;
|
|
if (team.banner && urlRegex2.test(team.banner)) {
|
|
embed.setImage(team.banner);
|
|
}
|
|
|
|
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
|
|
}
|
|
},
|
|
}; |