mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
const { EmbedBuilder, ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');
|
|
|
|
module.exports = {
|
|
name: 'christmas',
|
|
aliases: ['noel', 'noël'],
|
|
description: 'Calcule le nombre de jours jusqu\'à Noël.',
|
|
emote: '🎄',
|
|
utilisation: 'christmas ',
|
|
category: 'game',
|
|
|
|
async execute(message, args, client) {
|
|
let today = new Date();
|
|
let xmas = new Date(today.getFullYear(), 11, 24);
|
|
if (today.getMonth() == 11 && today.getDate() > 24) {
|
|
xmas.setFullYear(xmas.getFullYear() + 1);
|
|
}
|
|
let one_day = 1000 * 60 * 60 * 24;
|
|
let daysleft = Math.ceil((xmas.getTime() - today.getTime()) / (one_day));
|
|
let days = daysleft + 1;
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setColor("#FF0000")
|
|
.setTitle("🎄・Noël")
|
|
.setDescription(`${days} jours jusqu'à Noël`)
|
|
.setTimestamp();
|
|
|
|
const button = new ButtonBuilder()
|
|
.setEmoji('🎁')
|
|
.setCustomId('gift')
|
|
.setStyle(ButtonStyle.Danger);
|
|
|
|
const row = new ActionRowBuilder()
|
|
.addComponents(button);
|
|
|
|
const messageGift = await message.reply({ embeds: [embed], components: [row]});
|
|
|
|
const filter = i => i.customId === 'gift' && i.user.id === message.author.id;
|
|
const collector = messageGift.createMessageComponentCollector({ filter, time: 300000 });
|
|
collector.on('collect', async (interaction) => {
|
|
console.log('gift');
|
|
interaction.reply({ content: `Joyeux Noël ${message.author} ! 🎁`, ephemeral: true });
|
|
});
|
|
},
|
|
}; |