Merge branch 'devbot'

This commit is contained in:
SileNce5k 2023-04-16 14:40:15 +02:00
commit 2968079ad8
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
2 changed files with 20 additions and 3 deletions

View file

@ -5,13 +5,13 @@ module.exports = {
description: "Set a timer for a time in minutes.",
moreHelp: ["Usage:"
,"`<prefix>timer <time_in_minutes> <message_to_send>`"
,"`<prefix>timer <time>(d|h|m|s) <message_to_send>`"
,"`<prefix>timer <time>(d|h|m|s|t) <message_to_send>`"
,"Bot will mention you after the time has passed, with the custom message."],
execute({client, message, args}) {
if(args.length < 2)
return message.channel.send("Please specify a time, and a message to send after the timer has finished");
let currentUnixTime = Math.floor(new Date() / 1000);
let timeInSeconds = parseTime(args[0]);
let timeInSeconds = parseTime(args[0], currentUnixTime);
if(isNaN(timeInSeconds)){
return message.channel.send("Please specify a time, and a message to send after the timer has finished")
}

View file

@ -1,4 +1,4 @@
module.exports = function(time){
module.exports = function(time, currentUnixTime){
let timeInSeconds = parseFloat(time.slice(0, time.length - 1))
let letter = time.slice(time.length - 1)
if(!isNaN(letter)) return parseFloat(time) * 60;
@ -14,8 +14,25 @@ module.exports = function(time){
case "D":
timeInSeconds = timeInSeconds * 86400;
break;
case "T": // TODO: Make it so that I can have multiple letters per case, so that "TS" would work here.
timeInSeconds = timeInSeconds - currentUnixTime;
break;
case "W":
timeInSeconds = timeInSeconds * 86400 * 7;
break;
default:
timeInSeconds = NaN;
if(time.includes(':'))
timeInSeconds = getTime(time, currentUnixTime);
}
return timeInSeconds;
}
function getTime(time, currentUnixTime) {
return timeInSeconds;
}