mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 15:07:20 +02:00
131 lines
4.0 KiB
JavaScript
131 lines
4.0 KiB
JavaScript
const {
|
|
ButtonStyle,
|
|
ButtonBuilder,
|
|
ActionRowBuilder,
|
|
PermissionFlagsBits,
|
|
EmbedBuilder,
|
|
} = require("discord.js");
|
|
const embedColor = require("../../fonctions/embedColor.js");
|
|
|
|
module.exports = {
|
|
aliases: ["ban"],
|
|
description: "permet de ban un membre",
|
|
emote: "⏱️",
|
|
utilisation: "<@membre> <raison>",
|
|
permission: 0,
|
|
|
|
async execute(message, args, client) {
|
|
const authorPerms = message.channel.permissionsFor(message.author);
|
|
if (
|
|
(!authorPerms || !authorPerms.has(PermissionFlagsBits.banMembers)) &&
|
|
!client.config.owners.includes(message.author.id)
|
|
) {
|
|
return message.reply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle("Erreur")
|
|
.setDescription("❌ Vous n'avez pas les permissions pour expulser.")
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({
|
|
text: `Demandé par ${message.author.tag}`,
|
|
iconURL: message.author.displayAvatarURL(),
|
|
}),
|
|
],
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
}
|
|
let member = message.mentions.members.first(); // || message.guild.members.get(args[0]);
|
|
if (!member) {
|
|
return message.reply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle("Erreur")
|
|
.setDescription("❌ Veuillez spécifier un membre du serveur.")
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({
|
|
text: `Demandé par ${message.author.tag}`,
|
|
iconURL: message.author.displayAvatarURL(),
|
|
}),
|
|
],
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
}
|
|
const motif = args[1];
|
|
if (motif.length < 2) {
|
|
return message.reply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle("Erreur")
|
|
.setDescription("❌ Veuillez indiquer un motif.")
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({
|
|
text: `Demandé par ${message.author.tag}`,
|
|
iconURL: message.author.displayAvatarURL(),
|
|
}),
|
|
],
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
}
|
|
|
|
let reponse;
|
|
member.ban({ reason: motif }).then(async () => {
|
|
const btn = new ButtonBuilder()
|
|
.setCustomId("mp")
|
|
.setLabel("Prevenir le membre en MP")
|
|
.setStyle(ButtonStyle.Primary);
|
|
|
|
const row = new ActionRowBuilder().addComponents(btn);
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle("Membre banni !")
|
|
.setDescription(
|
|
"Vous avez banni: <@" + member + ">\nMotif: `" + motif + "`",
|
|
)
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({
|
|
text: `Demandé par ${message.author.tag}`,
|
|
iconURL: message.author.displayAvatarURL(),
|
|
});
|
|
reponse = await message.reply({
|
|
embeds: [embed],
|
|
components: [row],
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
});
|
|
|
|
const filter = (i) =>
|
|
i.customId === "mp" && i.user.id === message.author.id;
|
|
const collector = reponse.createMessageComponentCollector({
|
|
filter,
|
|
time: 30000,
|
|
});
|
|
collector.on("collect", async (interaction) => {
|
|
const embedBanni = new EmbedBuilder()
|
|
.setTitle("Bannissement !")
|
|
.setDescription(
|
|
"Vous avez été banni du serveur " +
|
|
interaction.guild.name +
|
|
", avec comme motif: `" +
|
|
motif +
|
|
"`",
|
|
)
|
|
.setColor("Red")
|
|
.setTimestamp();
|
|
member.send({ embeds: [embedBanni] });
|
|
interaction.reply({
|
|
content: "> **Le membre a été prevenu.**",
|
|
ephemeral: true,
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
});
|
|
|
|
collector.on("end", () => {
|
|
reponse.edit({ components: [], allowedMentions: { repliedUser: false } });
|
|
});
|
|
},
|
|
};
|