discord_bot/commands/misc/timer.js
SileNce5k 04f39582a4
Rewrite timer command to use JSON
* Rewrite parseTime to use seconds instead of ms
	*  Move parseTime to timer subdirectory

* Implement checkTimer and sendTimerReminder.
2022-06-09 18:44:30 +02:00

25 lines
No EOL
1,006 B
JavaScript

const parseTime = require('../../util/timer/parseTime');
module.exports = {
name: "timer",
description: "Set a timer for a time in minutes.",
moreHelp: ["Usage:"
,"`<prefix>timer <time_in_minutes> <message_to_send>`"
,"`<prefix>timer <time>(m|h|s) <message_to_send>`"
,"Bot will mention you after the time has passed, with the custom message."],
execute({client, message, args}) {
if(args.length < 2 || isNaN(time))
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 customMessage = args.slice(1).join(" ");
let reminderTime = currentUnixTime + timeInSeconds
const newTimer = {
"user": `${message.author.id}`,
"reminderDate": reminderTime,
"channel": `${message.channel.id}`,
"customMessage": `${customMessage}`
}
client.timers.push(newTimer);
message.channel.send(`I will remind you <t:${reminderTime}:R>`);
}
};