Compare commits

...

4 commits

Author SHA1 Message Date
425e1c3293
Update check if no subcommand is supplied
All checks were successful
CI / CI (push) Successful in 1m25s
2025-05-16 18:54:16 +02:00
22d1cbd570
Supply current unix timestamp with parseTime 2025-05-16 18:53:41 +02:00
ec5993e585
Use UTC for consistent behaviour 2025-05-15 04:39:27 +02:00
0dc6af5984
Return text to send instead of sending in util function 2025-05-15 04:38:50 +02:00
3 changed files with 6 additions and 5 deletions

View file

@ -38,7 +38,7 @@ module.exports = {
sendText = "Please specify a time, and a message to send after the timer has finished"; sendText = "Please specify a time, and a message to send after the timer has finished";
break; break;
} }
if(!isNaN(parseTime(args[0], Math.floor(new Date() / 1000)))) if(!isNaN(parseTime(args[0], Math.floor(new Date() / 1000)) || !isNaN(args[0])))
sendText = await createTimer(message, args); sendText = await createTimer(message, args);
break; break;
} }

View file

@ -48,6 +48,7 @@ client.whitelist = {
guild: new Collection(), guild: new Collection(),
user: new Collection() user: new Collection()
} }
process.env.TZ = "UTC";
createAndLoadWhitelistTable(client.whitelist); createAndLoadWhitelistTable(client.whitelist);

View file

@ -4,20 +4,20 @@ const sqlite3 = require('sqlite3').verbose();
module.exports = async function (message, args) { module.exports = async function (message, args) {
const databasePath = 'data/database.db' const databasePath = 'data/database.db'
if (args.length < 2) if (args.length < 2)
return message.channel.send("Please specify a time, and a message to send after the timer has finished"); return "Please specify a time, and a message to send after the timer has finished";
let currentUnixTime = Math.floor(new Date() / 1000); let currentUnixTime = Math.floor(new Date() / 1000);
let timeInSeconds; let timeInSeconds;
if(!isNaN(Date.parse(args[0])) && isNaN(parseTime(args[0]))){ if(!isNaN(Date.parse(args[0])) && isNaN(parseTime(args[0], currentUnixTime))){
timeInSeconds = timeUntil(args[0]).totalInSeconds; timeInSeconds = timeUntil(args[0]).totalInSeconds;
if(timeInSeconds < 0){ if(timeInSeconds < 0){
return message.channel.send("The date must not be in the past."); return "The date must not be in the past."
} }
}else { }else {
timeInSeconds = parseTime(args[0], currentUnixTime); timeInSeconds = parseTime(args[0], currentUnixTime);
} }
if (isNaN(timeInSeconds)) { if (isNaN(timeInSeconds)) {
return message.channel.send("Please specify a time, and a message to send after the timer has finished") return "Please specify a time, and a message to send after the timer has finished"
} }
let customMessage = args.slice(1).join(" ") let customMessage = args.slice(1).join(" ")
let reminderTime = currentUnixTime + timeInSeconds let reminderTime = currentUnixTime + timeInSeconds