From 0cde5ff7667c3aaf5c348a4a196f16b13d9415f2 Mon Sep 17 00:00:00 2001 From: Tutur33 Date: Sat, 17 Feb 2024 01:30:42 +0100 Subject: [PATCH] random command --- commands/utils/random.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 commands/utils/random.js diff --git a/commands/utils/random.js b/commands/utils/random.js new file mode 100644 index 0000000..59a14db --- /dev/null +++ b/commands/utils/random.js @@ -0,0 +1,30 @@ +const { EmbedBuilder} = require('discord.js'); +const fs = require('fs'); +const path = require('path'); + +module.exports = { + name: 'random', + description: 'Affiche un nombre aléatoire entre 2 nombres donnés', + emote: '🎲', + utilisation: 'random [min] [max]', + category: 'utils', + async execute(message, args, client) { + if (!args[0] || !args[1]) { + return message.reply('Veuillez spécifier 2 nombres.'); + } + if (isNaN(args[0]) || isNaN(args[1])) { + return message.reply('Veuillez spécifier des nombres valides.'); + } + const min = Math.ceil(args[0]); + const max = Math.floor(args[1]); + const random = Math.floor(Math.random() * (max - min + 1)) + min; + const embed = new EmbedBuilder() + .setTitle('Nombre aléatoire') + .setDescription(`Le nombre aléatoire entre \`${min}\` et \`${max}\` est : \`\`\`${random}\`\`\``) + .setColor('#0099ff') + .setTimestamp() + .setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL({dynamic: true})}) + + message.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file