mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 15:07:20 +02:00
93 lines
3.3 KiB
JavaScript
93 lines
3.3 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) {
|
|
let subCommand = args[0].toLowerCase();
|
|
subCommand = subCommand.replice("n", "name");
|
|
subCommand = subCommand.replice("nom", "name");
|
|
subCommand = subCommand.replice("noms", "name");
|
|
subCommand = subCommand.replice("banniere", "banner");
|
|
subCommand = subCommand.replice("bannière", "banner");
|
|
subCommand = subCommand.replice("b", "banner");
|
|
subCommand = subCommand.replice("i", "icon");
|
|
subCommand = subCommand.replice("p", "icon");
|
|
subCommand = subCommand.replice("photo", "icon");
|
|
subCommand = subCommand.replice("icone", "icon");
|
|
subCommand = subCommand.replice("d", "description");
|
|
|
|
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 },
|
|
});
|
|
}
|
|
},
|
|
};
|