Update return if teamid = NaN

This commit is contained in:
*x1
2024-05-28 00:48:37 +02:00
parent 6f6016b44c
commit a12249d672
+50 -42
View File
@@ -10,61 +10,69 @@ module.exports = {
permission: 0,
async execute(message, args, client) {
if (args.length > 0) {
const teamID = args[0].toLowerCase();
if (args.length <= 2) {
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() });
const team = await new Promise((resolve, reject) => {
db.get(`SELECT * FROM teams WHERE guildId = ? AND id = ?`, [message.guild.id, teamID], (err, row) => {
if (err) reject(err);
resolve(row);
});
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
const teamID = args[0].toLowerCase();
const team = await new Promise((resolve, reject) => {
db.get(`SELECT * FROM teams WHERE guildId = ? AND id = ?`, [message.guild.id, teamID], (err, row) => {
if (err) reject(err);
resolve(row);
});
});
const teamRep = team.reputation
if (teamRep < 4) {
const embed = new EmbedBuilder()
.setTitle('Ajout de cadenas impossible')
.setDescription(`❌ Vous n'avez pas assez de reputation. Il faut \`4\` reputation mais la team n'a que \`${teamRep}\` reputation`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
const teamRep = team.reputation
if (teamRep < 4) {
const embed = new EmbedBuilder()
.setTitle('Ajout de cadenas impossible')
.setDescription(`❌ Vous n'avez pas assez de reputation. Il faut \`4\` reputation mais la team n'a que \`${teamRep}\` reputation`)
.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 } });
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
db.run(`UPDATE teams SET reputation = reputation - 4 WHERE guildId =? AND Id =?`, [message.guild.id, teamID], (err) => {
if (err) {
console.log(`${err}`.red)
}
});
db.run(`UPDATE teams SET reputation = reputation - 4 WHERE guildId =? AND Id =?`, [message.guild.id, teamID], (err) => {
if (team.padlock < 5) {
db.run(`UPDATE teams SET padlock = padlock + 1 WHERE guildId =? AND Id =?`, [message.guild.id, teamID], (err) => {
if (err) {
console.log(`${err}`.red)
}
});
if (team.padlock < 5) {
db.run(`UPDATE teams SET padlock = padlock + 1 WHERE guildId =? AND Id =?`, [message.guild.id, teamID], (err) => {
if (err) {
console.log(`${err}`.red)
}
});
const embed = new EmbedBuilder()
.setTitle('Ajout de cadenas réussi !')
.setDescription('Vous avez ajouter un cadenas à team `' + team.name + '`, cette team à maintement `' + team.padlock + 1 + '` cadenas !')
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setImage()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
const embed = new EmbedBuilder()
.setTitle('Ajout de cadenas réussi !')
.setDescription('Vous avez ajouter un cadenas à team `' + team.name + '`, cette team à maintement `' + team.padlock + 1 + '` 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], allowedMentions: { repliedUser: false } });
} else {
const embed = new EmbedBuilder()
.setTitle('Ajout de cadenas impossible')
.setDescription('`' + team.name + '` à le maximum de cadenas (`' + team.padlock + 1 + '` 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], allowedMentions: { repliedUser: false } });
} else {
const embed = new EmbedBuilder()
.setTitle('Ajout de cadenas impossible')
.setDescription('`' + team.name + '` à le maximum de cadenas (`' + team.padlock + 1 + '` 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], allowedMentions: { repliedUser: false } });
}
message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
},
};