mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-15 08:13:06 +02:00
62 lines
2.4 KiB
JavaScript
62 lines
2.4 KiB
JavaScript
const { GiveawaysManager } = require('discord-giveaways');
|
|
const ms = require('ms');
|
|
|
|
module.exports = {
|
|
name: 'giveaway',
|
|
utilisation: 'giveaway <durée> <prix> <nombre de gagnants>',
|
|
description: 'Crée un giveaway avec une durée, un prix et un nombre de gagnants spécifiés.',
|
|
emote: '🎉',
|
|
category: 'gestion',
|
|
|
|
async execute(message, args, client) {
|
|
if (args.length < 3) {
|
|
return message.channel.send('Veuillez fournir une durée, un prix et un nombre de gagnants.');
|
|
}
|
|
|
|
const duration = args[0];
|
|
const prize = args.slice(1, -1).join(' ');
|
|
const winnersCount = parseInt(args[args.length - 1]);
|
|
|
|
// Vérifie si la durée est valide
|
|
if (isNaN(ms(duration))) {
|
|
return message.channel.send('Veuillez fournir une durée valide.');
|
|
}
|
|
|
|
// Vérifie si le nombre de gagnants est valide
|
|
if (isNaN(winnersCount) || winnersCount < 1) {
|
|
return message.channel.send('Veuillez fournir un nombre valide de gagnants.');
|
|
}
|
|
|
|
// Crée le giveaway
|
|
const giveawayChannel = message.channel;
|
|
const giveawayDuration = ms(duration);
|
|
const giveawayWinners = winnersCount;
|
|
client.giveawaysManager.create(giveawayChannel, {
|
|
duration: giveawayDuration,
|
|
prize: prize,
|
|
winnerCount: giveawayWinners,
|
|
messages: {
|
|
giveaway: "🎉 **GIVEAWAY** 🎉",
|
|
giveawayEnded: "🎉 **GIVEAWAY TERMINÉ** 🎉",
|
|
timeRemaining: "Temps restant : **{duration}**!",
|
|
inviteToParticipate: "Réagissez avec 🎉 pour participer!",
|
|
winMessage: "Félicitations, {winners}! Vous avez gagné **{prize}**!",
|
|
embedFooter: "Giveaway",
|
|
noWinner: "Giveaway annulé, aucune participation valide.",
|
|
hostedBy: "Hébergé par: {user}",
|
|
winners: "gagnant(s)",
|
|
endedAt: "Se termine le",
|
|
units: {
|
|
seconds: "secondes",
|
|
minutes: "minutes",
|
|
hours: "heures",
|
|
days: "jours",
|
|
pluralS: false
|
|
}
|
|
}
|
|
}).then((gData) => {
|
|
console.log(gData); // Donne des informations sur le giveaway
|
|
});
|
|
message.channel.send(`Giveaway créé !`);
|
|
},
|
|
}; |