This commit is contained in:
arthur
2024-04-28 00:39:04 +02:00
parent 7f412ec02e
commit 92ec597798
2 changed files with 43 additions and 19 deletions
+40 -16
View File
@@ -1,20 +1,44 @@
const { EmbedBuilder, ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');
module.exports = { module.exports = {
name: 'christmas', name: 'christmas',
description: 'Calcule le nombre de jours jusqu\'à Noël.', aliases: ['noel', 'noël'],
emote: '🎄', description: 'Calcule le nombre de jours jusqu\'à Noël.',
utilisation: 'christmas ', emote: '🎄',
category: 'game', utilisation: 'christmas ',
category: 'game',
async execute(message, args, client) { async execute(message, args, client) {
let today = new Date(); let today = new Date();
let xmas = new Date(today.getFullYear(), 11, 24); let xmas = new Date(today.getFullYear(), 11, 24);
if (today.getMonth() == 11 && today.getDate() > 24) { if (today.getMonth() == 11 && today.getDate() > 24) {
xmas.setFullYear(xmas.getFullYear() + 1); xmas.setFullYear(xmas.getFullYear() + 1);
} }
let one_day = 1000 * 60 * 60 * 24; let one_day = 1000 * 60 * 60 * 24;
let daysleft = Math.ceil((xmas.getTime() - today.getTime()) / (one_day)); let daysleft = Math.ceil((xmas.getTime() - today.getTime()) / (one_day));
let days = daysleft + 1; let days = daysleft + 1;
message.reply(`🎄・Noël\n${days} jours jusqu'à Noël`); 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 });
});
},
}; };
+3 -3
View File
@@ -14,16 +14,16 @@ module.exports = {
.setLabel('🔄') .setLabel('🔄')
.setStyle(ButtonStyle.Primary); .setStyle(ButtonStyle.Primary);
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents(ping); .addComponents(ping);
const sentMessage = await message.reply({ const sentMessage = await message.reply({
content: `la latence est de : ${client.ws.ping}`, content: `la latence est de : ${client.ws.ping}`,
components: [row], components: [row],
}); });
const filter = i => i.customId === 'confirm' && i.user.id === message.author.id; const filter = i => i.customId === 'confirm' && i.user.id === message.author.id;
const collector = sentMessage.createMessageComponentCollector({ filter, time: 15000 }) const collector = sentMessage.createMessageComponentCollector({ filter, time: 300000 })
collector.on('collect', async (interaction) => { collector.on('collect', async (interaction) => {
sentMessage.edit({ sentMessage.edit({
content: `La latence est de : ${client.ws.ping}`, content: `La latence est de : ${client.ws.ping}`,