mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 23:36:29 +02:00
179 lines
5.4 KiB
JavaScript
179 lines
5.4 KiB
JavaScript
const {
|
|
ButtonStyle,
|
|
ButtonBuilder,
|
|
ActionRowBuilder,
|
|
PermissionFlagsBits,
|
|
EmbedBuilder,
|
|
} = require("discord.js");
|
|
const embedColor = require("../../fonctions/embedColor.js");
|
|
|
|
module.exports = {
|
|
aliases: ["timeout"],
|
|
description: "permet de mute un membre",
|
|
emote: "⏱️",
|
|
utilisation: "<@membre> <temps> <raison>",
|
|
permission: 0,
|
|
|
|
async execute(message, args, client) {
|
|
const authorPerms = message.channel.permissionsFor(message.author);
|
|
if (
|
|
(!authorPerms || !authorPerms.has(PermissionFlagsBits.MuteMembers)) &&
|
|
!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 },
|
|
});
|
|
}
|
|
|
|
if (!args[0] || !args[1] || !args[2]) {
|
|
return message.reply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle("Erreur")
|
|
.setDescription(
|
|
"❌ Veuillez respecter ce format : <@membre|membreId> <min> <raison>.",
|
|
)
|
|
.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 },
|
|
});
|
|
}
|
|
|
|
let time = args[1];
|
|
if (time.length <= 3 || !time.includes("min")) {
|
|
return message.reply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle("Erreur")
|
|
.setDescription("❌ Veuillez indiquer une durée valide <`x`min>.")
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({
|
|
text: `Demandé par ${message.author.tag}`,
|
|
iconURL: message.author.displayAvatarURL(),
|
|
}),
|
|
],
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
}
|
|
time = time.replace("min", "");
|
|
|
|
const motif = args[2];
|
|
if (motif.length <= 2) {
|
|
return message.reply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setTitle("Erreur")
|
|
.setDescription(
|
|
"❌ Veuillez indiquer un motif (minimum 3caractère).",
|
|
)
|
|
.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.timeout(time * 60 * 1000, 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 mute !")
|
|
.setDescription(
|
|
"Vous avez mute: <@" +
|
|
member +
|
|
">\nTemps: `" +
|
|
time +
|
|
"`min\nMotif: `" +
|
|
motif +
|
|
"`",
|
|
)
|
|
.setColor(await embedColor(message.author.id, message.guild.id))
|
|
.setTimestamp()
|
|
.setFooter({
|
|
text: `Demandé par ${message.author.tag}`,
|
|
iconURL: message.author.displayAvatarURL(),
|
|
});
|
|
reponse = 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 embedkick = new EmbedBuilder()
|
|
.setTitle("Expulsion !")
|
|
.setDescription(
|
|
"Vous avez été expulser du serveur " +
|
|
interaction.guild.name +
|
|
", avec comme motif: `" +
|
|
motif +
|
|
"`",
|
|
)
|
|
.setColor("Red")
|
|
.setTimestamp();
|
|
member.send({ embeds: [embedkick] });
|
|
interaction.reply({
|
|
content: "> **Le membre a été prevenu.**",
|
|
ephemeral: true,
|
|
allowedMentions: { repliedUser: false },
|
|
});
|
|
});
|
|
|
|
collector.on("end", () => {
|
|
reponse.edit({ components: [], allowedMentions: { repliedUser: false } });
|
|
});
|
|
},
|
|
};
|