Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
- module.exports = {
- data: new SlashCommandBuilder()
- .setName("calculate-time")
- .setDescription("Calculate a time in milli seconds")
- .addIntegerOption(option => option
- .setName("years")
- .setDescription("the amount of years")
- .setRequired(false)
- )
- .addIntegerOption(option => option
- .setName("months")
- .setDescription("the amount of months")
- .setRequired(false)
- )
- .addIntegerOption(option => option
- .setName("weeks")
- .setDescription("the amount of weeks")
- .setRequired(false)
- )
- .addIntegerOption(option => option
- .setName("days")
- .setDescription("the amount of days")
- .setRequired(false)
- )
- .addIntegerOption(option => option
- .setName("hours")
- .setDescription("the amount of hours")
- .setRequired(false)
- )
- .addIntegerOption(option => option
- .setName("minutes")
- .setDescription("the amount of minutes")
- .setRequired(false)
- )
- .addIntegerOption(option => option
- .setName("seconds")
- .setDescription("the amount of seconds")
- .setRequired(false)
- ),
- async execute (interaction) {
- const { options } = interaction;
- const years = options.getInteger("years") || "0";
- const months = options.getInteger("months") || "0";
- const weeks = options.getInteger("weeks") || "0";
- const days = options.getInteger("days") || "0";
- const hours = options.getInteger("hours") || "0";
- const minutes = options.getInteger("minutes") || "0";
- const seconds = options.getInteger("seconds") || "0";
- const year = "31536000000";
- const month = "2628000000";
- const week = "604800000";
- const day = "86400000";
- const hour = "3600000";
- const minute = "60000";
- const second = "1000";
- const xyear = Math.floor(year * years);
- const xmonth = Math.floor(month * months);
- const xweek = Math.floor(week * weeks);
- const xday = Math.floor(day * days);
- const xhour = Math.floor(hour * hours);
- const xminute = Math.floor(minute * minutes);
- const xsecond = Math.floor(second * seconds);
- const ALL = Math.floor(xyear + xmonth + xweek + xday + xhour + xminute + xsecond)
- const embed = new EmbedBuilder()
- .setTitle("Your results are here!")
- .setDescription(`Exactly MS: ||${ALL}||`)
- .addFields(
- {name: `${years} Years:`, value: `${xyear}`, inline: true},
- {name: `${months} Months:`, value: `${xmonth}`, inline: true},
- {name: `${weeks} Weeks:`, value: `${xweek}`, inline: true},
- {name: `${days} Days:`, value: `${xday}`, inline: true},
- {name: `${hours} Hours:`, value: `${xhour}`, inline: true},
- {name: `${minutes} Minutes::`, value: `${xminute}`, inline: true},
- {name: `${seconds} Seconds:`, value: `${xsecond}`, inline: true},
- )
- .setColor("Blue")
- .setTimestamp()
- await interaction.reply({
- embeds: [embed]
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment