UNPKG

discord-giveaway-easy

Version:

A module allowing the simple creation of a discord giveaway with your bot supported by Discord.js^14.0.0

76 lines (64 loc) 1.98 kB
module.exports = class Time { /** * * @param {String} time * @exemple * ``` * let time = new Time("10m"); // 10 minutes * ``` */ constructor(time) { this.time = time; this.pressTime = []; } /** * * @returns if "new Time()" is got argument "10m" then he's equal 10 minutes, so Secondes() function will return 10 minutes in secondes; Same for ms() function but she's will return 10 minute in milliseconds. */ ms() { if (this.time.includes("m")) { let Time = this.time.replace("m", "") let Finaltime = Number(Time) * 60 return Finaltime * 1000; } if (this.time.includes("h")) { let Time = this.time.replace("h", "") let Finaltime = Number(Time) * 3600 return Finaltime * 1000; } if (this.time.includes("d")) { let Time = this.time.replace("d", "") let Finaltime = Number(Time) * 86400 return Finaltime * 1000; } } /** * * @returns if "new Time()" is got argument "10m" then he's equal 10 minutes, so ms() function will return 10 minutes in milliseconds. Already said in the description of Secondes() function. */ msByTheTime() { if (this.time.includes("m")) { let Time = this.time.replace("m", "") let Finaltime = Number(Time) * 60 return Math.floor((Date.now() / 1000) + (Finaltime)); } if (this.time.includes("h")) { let Time = this.time.replace("h", "") let Finaltime = Number(Time) * 3600 return Math.floor((Date.now() / 1000) + (Finaltime)); } if (this.time.includes("d")) { let Time = this.time.replace("d", "") let Finaltime = Number(Time) * 86400 return Math.floor((Date.now() / 1000) + (Finaltime)); } } /** * * @param {Number} newDate */ timeRemaining(newDate) { let date = Math.floor((Date.now() / 1000) + (newDate)) return date; } }