toowake

create-ms.js

May 22nd, 2023
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
  2.  
  3. module.exports = {
  4.     data: new SlashCommandBuilder()
  5.     .setName("calculate-time")
  6.     .setDescription("Calculate a time in milli seconds")
  7.     .addIntegerOption(option => option
  8.         .setName("years")
  9.         .setDescription("the amount of years")
  10.         .setRequired(false)
  11.     )
  12.     .addIntegerOption(option => option
  13.         .setName("months")
  14.         .setDescription("the amount of months")
  15.         .setRequired(false)
  16.     )
  17.     .addIntegerOption(option => option
  18.         .setName("weeks")
  19.         .setDescription("the amount of weeks")
  20.         .setRequired(false)
  21.     )
  22.     .addIntegerOption(option => option
  23.         .setName("days")
  24.         .setDescription("the amount of days")
  25.         .setRequired(false)
  26.     )
  27.     .addIntegerOption(option => option
  28.         .setName("hours")
  29.         .setDescription("the amount of hours")
  30.         .setRequired(false)
  31.     )
  32.     .addIntegerOption(option => option
  33.         .setName("minutes")
  34.         .setDescription("the amount of minutes")
  35.         .setRequired(false)
  36.     )
  37.     .addIntegerOption(option => option
  38.         .setName("seconds")
  39.         .setDescription("the amount of seconds")
  40.         .setRequired(false)
  41.     ),
  42.  
  43.     async execute (interaction) {
  44.         const { options } = interaction;
  45.  
  46.         const years = options.getInteger("years") || "0";
  47.         const months = options.getInteger("months") || "0";
  48.         const weeks = options.getInteger("weeks") || "0";
  49.         const days = options.getInteger("days") || "0";
  50.         const hours = options.getInteger("hours") || "0";
  51.         const minutes = options.getInteger("minutes") || "0";
  52.         const seconds = options.getInteger("seconds") || "0";
  53.  
  54.         const year = "31536000000";
  55.         const month = "2628000000";
  56.         const week = "604800000";
  57.         const day = "86400000";
  58.         const hour = "3600000";
  59.         const minute = "60000";
  60.         const second = "1000";
  61.  
  62.         const xyear = Math.floor(year * years);
  63.         const xmonth = Math.floor(month * months);
  64.         const xweek = Math.floor(week * weeks);
  65.         const xday = Math.floor(day * days);
  66.         const xhour = Math.floor(hour * hours);
  67.         const xminute = Math.floor(minute * minutes);
  68.         const xsecond = Math.floor(second * seconds);
  69.  
  70.         const ALL = Math.floor(xyear + xmonth + xweek + xday + xhour + xminute + xsecond)
  71.  
  72.         const embed = new EmbedBuilder()
  73.         .setTitle("Your results are here!")
  74.         .setDescription(`Exactly MS: ||${ALL}||`)
  75.         .addFields(
  76.             {name: `${years} Years:`, value: `${xyear}`, inline: true},
  77.             {name: `${months} Months:`, value: `${xmonth}`, inline: true},
  78.             {name: `${weeks} Weeks:`, value: `${xweek}`, inline: true},
  79.             {name: `${days} Days:`, value: `${xday}`, inline: true},
  80.             {name: `${hours} Hours:`, value: `${xhour}`, inline: true},
  81.             {name: `${minutes} Minutes::`, value: `${xminute}`, inline: true},
  82.             {name: `${seconds} Seconds:`, value: `${xsecond}`, inline: true},
  83.         )
  84.         .setColor("Blue")
  85.         .setTimestamp()
  86.  
  87.         await interaction.reply({
  88.             embeds: [embed]
  89.         })
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment