Compare commits
3 commits
2c90c20e50
...
8c642f16f0
Author | SHA1 | Date | |
---|---|---|---|
8c642f16f0 | |||
9062b32009 | |||
2bb0f38701 |
3 changed files with 6 additions and 7 deletions
|
@ -4,7 +4,7 @@ const parseTime = require('../../util/timer/parseTime');
|
|||
const showTimer = require('../../util/timer/showTimer');
|
||||
module.exports = {
|
||||
name: "timer",
|
||||
description: "Set a timer for a time in minutes.",
|
||||
description: "Set a timer for a date or time duration.",
|
||||
moreHelp: ["Usage:"
|
||||
,"`<prefix>timer [add|create] <time_in_minutes> <message_to_send>`"
|
||||
,"`<prefix>timer <time>(d|h|m|s|t) <message_to_send>`"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const fs = require('fs');
|
||||
const parseTime = require('./parseTime');
|
||||
const timeSince = require('./timeSince');
|
||||
const timeUntil = require('./timeUntil');
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
module.exports = async function (message, args) {
|
||||
const databasePath = 'data/database.db'
|
||||
|
@ -10,7 +10,7 @@ module.exports = async function (message, args) {
|
|||
|
||||
let timeInSeconds;
|
||||
if(Date.parse(args[0]) && parseFloat(args[0]).toString() === args[0]){
|
||||
timeInSeconds = timeSince(args[0]);
|
||||
timeInSeconds = timeUntil(args[0]);
|
||||
}else {
|
||||
timeInSeconds = parseTime(args[0], currentUnixTime);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
module.exports = function(timeElapsed) {
|
||||
|
||||
let countDownDate = new Date(timeElapsed).getTime();
|
||||
module.exports = function(targetTime) {
|
||||
let countDownDate = new Date(targetTime).getTime();
|
||||
let now = new Date().getTime();
|
||||
|
||||
let distance = countDownDate - now;
|
||||
|
@ -9,7 +8,7 @@ module.exports = function(timeElapsed) {
|
|||
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||
|
||||
if (seconds < 0) {
|
||||
if (seconds < 0) { // Due to how the math above works, if the input time is in the past, the time will be off by 1.
|
||||
days = days + 1;
|
||||
hours = hours + 1;
|
||||
minutes = minutes + 1;
|
Loading…
Add table
Add a link
Reference in a new issue