Add time parser for timer command
* Fix grammar * Fix countdown off by 4 seconds
This commit is contained in:
parent
5f4a0056d7
commit
e676730f0c
2 changed files with 22 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
|||
const parseTime = require('../../util/parseTime');
|
||||
module.exports = {
|
||||
name: "timer",
|
||||
description: "Set a timer for a time in minutes.",
|
||||
|
@ -5,14 +6,13 @@ module.exports = {
|
|||
execute({message, args}) {
|
||||
if(args.length < 2)
|
||||
return message.channel.send("Please specify a time in minutes, and a message to send after the timer has finished");
|
||||
let time = parseInt(args[0]);
|
||||
let time = parseTime(args[0]);
|
||||
if(isNaN(time))
|
||||
return message.channel.send("Specify a time in number of minutes");
|
||||
time = time * 60000;
|
||||
let sendText = args.slice(1).join(" ");
|
||||
setTimeout(function(){
|
||||
message.channel.send(`<@${message.author.id}>, ${sendText}`);
|
||||
}, time);
|
||||
message.channel.send(`I will remind you in <t:${Math.floor(new Date() / 1000) + (time / 1000)}:R>`);
|
||||
message.channel.send(`I will remind you <t:${Math.floor(new Date() / 1000) + (time / 1000) - 4}:R>`);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue