mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 23:36:29 +02:00
54 lines
2.5 KiB
JavaScript
54 lines
2.5 KiB
JavaScript
const { EmbedBuilder } = require('discord.js');
|
|
const db = require('../../fonctions/database.js');
|
|
const embedColor = require('../../fonctions/embedColor.js');
|
|
|
|
module.exports = {
|
|
aliases: ['tedit'],
|
|
description: 'Modifie les informations de votre team.',
|
|
emote: '🛡️',
|
|
utilisation: '<nom|bannière|photo|description> <nouvelle valeur>',
|
|
permission: 0,
|
|
|
|
async execute(message, args, client) {
|
|
if (args.length > 0) {
|
|
const subCommand = args[0].toLowerCase();
|
|
const newValue = args.slice(1).join(' ');
|
|
|
|
if (['name', 'banner', 'icon', 'description'].includes(subCommand)) {
|
|
await new Promise((resolve, reject) => {
|
|
db.run(`UPDATE teams SET ${subCommand} = ? WHERE guildId = ? AND id = (SELECT teamId FROM users WHERE guildId = ? AND userId = ?)`, [newValue, message.guild.id, message.guild.id, message.author.id], (err) => {
|
|
if (err) reject(err);
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('🛡️ Modification de team')
|
|
.setDescription(`La ${subCommand} de votre team a été mise à jour.`)
|
|
.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 embed = new EmbedBuilder()
|
|
.setTitle('🛡️ Modification de team')
|
|
.setDescription('❌ Vous devez spécifier ce que vous voulez modifier (name, banner, icon ou description).')
|
|
.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 embed = new EmbedBuilder()
|
|
.setTitle('🛡️ Modification de team')
|
|
.setDescription('Veuillez spécifier ce que vous voulez modifier et la nouvelle valeur.')
|
|
.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 } });
|
|
}
|
|
},
|
|
}; |