Update
This commit is contained in:
@@ -1,133 +1,119 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
||||
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, MessageFlags } = require('discord.js');
|
||||
const db = require('../../functions/database/db.js');
|
||||
const { colors } = require('../../utils/constants');
|
||||
const { sendLog } = require('../../utils/helpers');
|
||||
|
||||
module.exports = {
|
||||
category: 'info',
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('adminprofil')
|
||||
.setDescription('Administrer les profils utilisateurs (Admin uniquement)')
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName('reset')
|
||||
.setDescription('Réinitialiser le profil d\'un utilisateur')
|
||||
.addUserOption(option =>
|
||||
option.setName('user')
|
||||
.setDescription('L\'utilisateur dont tu veux réinitialiser le profil')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('type')
|
||||
.setDescription('Ce qui doit être réinitialisé')
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'Signature', value: 'signature' },
|
||||
{ name: 'Tout le profil', value: 'all' }
|
||||
))
|
||||
.addStringOption(option =>
|
||||
option.setName('reason')
|
||||
.setDescription('Raison de la réinitialisation')
|
||||
.setRequired(false))),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
// Vérifier les permissions (Admin uniquement)
|
||||
if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) {
|
||||
return interaction.editReply({
|
||||
content: '❌ Tu n\'as pas la permission d\'utiliser cette commande. (Administrateur requis)'
|
||||
});
|
||||
}
|
||||
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
|
||||
if (subcommand === 'reset') {
|
||||
const target = interaction.options.getUser('user');
|
||||
const resetType = interaction.options.getString('type');
|
||||
const reason = interaction.options.getString('reason') || 'Aucune raison fournie';
|
||||
|
||||
if (!target) {
|
||||
return interaction.editReply({
|
||||
content: '❌ Aucun utilisateur spécifié !'
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
// Récupérer le profil actuel
|
||||
const [profiles] = await db.query(
|
||||
'SELECT * FROM user_profiles WHERE userId = ? AND guildId = ?',
|
||||
[target.id, interaction.guild.id]
|
||||
);
|
||||
|
||||
if (profiles.length === 0) {
|
||||
return interaction.editReply({
|
||||
content: `❌ ${target.tag} n'a pas de profil à réinitialiser.`
|
||||
});
|
||||
}
|
||||
|
||||
const profile = profiles[0];
|
||||
|
||||
if (resetType === 'signature') {
|
||||
// Réinitialiser uniquement la signature
|
||||
await db.query(
|
||||
'UPDATE user_profiles SET signature = NULL, updatedAt = ? WHERE userId = ? AND guildId = ?',
|
||||
[Date.now(), target.id, interaction.guild.id]
|
||||
);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('✅ Signature Réinitialisée')
|
||||
.setColor(colors.success)
|
||||
.setDescription(`La signature de ${target.toString()} a été réinitialisée.`)
|
||||
.addFields(
|
||||
{ name: '👤 Utilisateur', value: `${target.tag}`, inline: true },
|
||||
{ name: '📝 Raison', value: reason, inline: false }
|
||||
)
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} else if (resetType === 'all') {
|
||||
// Réinitialiser tout le profil
|
||||
await db.query(
|
||||
'DELETE FROM user_profiles WHERE userId = ? AND guildId = ?',
|
||||
[target.id, interaction.guild.id]
|
||||
);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('✅ Profil Réinitialisé')
|
||||
.setColor(colors.success)
|
||||
.setDescription(`Le profil de ${target.toString()} a été complètement réinitialisé.`)
|
||||
.addFields(
|
||||
{ name: '👤 Utilisateur', value: `${target.tag}`, inline: true },
|
||||
{ name: '📝 Raison', value: reason, inline: false }
|
||||
)
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
// Logger l'action
|
||||
const logEmbed = new EmbedBuilder()
|
||||
.setTitle('🔄 Profil Réinitialisé (Admin)')
|
||||
.setColor(colors.warning)
|
||||
.setDescription(`Le profil de ${target.toString()} a été réinitialisé.`)
|
||||
.addFields(
|
||||
{ name: '👤 Utilisateur', value: `${target.tag} (${target.id})`, inline: true },
|
||||
{ name: '⚙️ Admin', value: `${interaction.user.tag} (${interaction.user.id})`, inline: true },
|
||||
{ name: '🔄 Type', value: resetType === 'signature' ? 'Signature' : 'Tout le profil', inline: true },
|
||||
{ name: '📝 Raison', value: reason, inline: false }
|
||||
)
|
||||
.setFooter({ text: 'France Femboy Bot • Administration' })
|
||||
.setTimestamp();
|
||||
|
||||
await sendLog(interaction.guild, logEmbed);
|
||||
|
||||
} catch (err) {
|
||||
console.error('Erreur lors de la réinitialisation du profil:', err);
|
||||
await interaction.editReply({
|
||||
content: `❌ Erreur lors de la réinitialisation du profil: ${err.message}`
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
category: 'info',
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('adminprofil')
|
||||
.setDescription('Administrer les profils utilisateurs (Admin uniquement)')
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName('reset')
|
||||
.setDescription('Réinitialiser le profil d\'un utilisateur')
|
||||
.addUserOption(option =>
|
||||
option.setName('user')
|
||||
.setDescription('L\'utilisateur dont tu veux réinitialiser le profil')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('type')
|
||||
.setDescription('Ce qui doit être réinitialisé')
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'Signature', value: 'signature' },
|
||||
{ name: 'Tout le profil', value: 'all' }
|
||||
))
|
||||
.addStringOption(option =>
|
||||
option.setName('reason')
|
||||
.setDescription('Raison de la réinitialisation')
|
||||
.setRequired(false))),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
||||
|
||||
if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) {
|
||||
return interaction.editReply({
|
||||
content: '❌ Tu n\'as pas la permission d\'utiliser cette commande. (Administrateur requis)'
|
||||
});
|
||||
}
|
||||
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
|
||||
if (subcommand === 'reset') {
|
||||
const target = interaction.options.getUser('user');
|
||||
const resetType = interaction.options.getString('type');
|
||||
const reason = interaction.options.getString('reason') || 'Aucune raison fournie';
|
||||
|
||||
if (!target) return interaction.editReply({ content: '❌ Aucun utilisateur spécifié !' });
|
||||
|
||||
try {
|
||||
const [profiles] = await db.query(
|
||||
'SELECT * FROM user_profiles WHERE userId = ? AND guildId = ?',
|
||||
[target.id, interaction.guild.id]
|
||||
);
|
||||
|
||||
if (profiles.length === 0) {
|
||||
return interaction.editReply({
|
||||
content: `❌ ${target.tag} n'a pas de profil à réinitialiser.`
|
||||
});
|
||||
}
|
||||
|
||||
if (resetType === 'signature') {
|
||||
await db.query(
|
||||
'UPDATE user_profiles SET signature = NULL, updatedAt = ? WHERE userId = ? AND guildId = ?',
|
||||
[Date.now(), target.id, interaction.guild.id]
|
||||
);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('✅ Signature Réinitialisée')
|
||||
.setColor(colors.success)
|
||||
.setDescription(`La signature de ${target.toString()} a été réinitialisée.`)
|
||||
.addFields(
|
||||
{ name: '👤 Utilisateur', value: `${target.tag}`, inline: true },
|
||||
{ name: '📝 Raison', value: reason, inline: false }
|
||||
)
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} else if (resetType === 'all') {
|
||||
await db.query(
|
||||
'DELETE FROM user_profiles WHERE userId = ? AND guildId = ?',
|
||||
[target.id, interaction.guild.id]
|
||||
);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('✅ Profil Réinitialisé')
|
||||
.setColor(colors.success)
|
||||
.setDescription(`Le profil de ${target.toString()} a été complètement réinitialisé.`)
|
||||
.addFields(
|
||||
{ name: '👤 Utilisateur', value: `${target.tag}`, inline: true },
|
||||
{ name: '📝 Raison', value: reason, inline: false }
|
||||
)
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
const logEmbed = new EmbedBuilder()
|
||||
.setTitle('🔄 Profil Réinitialisé (Admin)')
|
||||
.setColor(colors.warning)
|
||||
.setDescription(`Le profil de ${target.toString()} a été réinitialisé.`)
|
||||
.addFields(
|
||||
{ name: '👤 Utilisateur', value: `${target.tag} (${target.id})`, inline: true },
|
||||
{ name: '⚙️ Admin', value: `${interaction.user.tag} (${interaction.user.id})`, inline: true },
|
||||
{ name: '🔄 Type', value: resetType === 'signature' ? 'Signature' : 'Tout le profil', inline: true },
|
||||
{ name: '📝 Raison', value: reason, inline: false }
|
||||
)
|
||||
.setFooter({ text: 'Femboy Croissant Bot • Administration' })
|
||||
.setTimestamp();
|
||||
|
||||
await sendLog(interaction.guild, { embeds: [logEmbed] });
|
||||
|
||||
} catch (err) {
|
||||
console.error('Erreur adminprofil:', err);
|
||||
await interaction.editReply({ content: `❌ Erreur: ${err.message}` });
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user