helpful output

This commit is contained in:
reality 2016-01-15 23:22:59 +00:00
parent dc00730168
commit 8c06ec9dcf
2 changed files with 9 additions and 2 deletions

View File

@ -21,7 +21,9 @@ var commands = function(dbot) {
var msTimeout = new Date(new Date().getTime() + (parseFloat(duration) * 60000)); var msTimeout = new Date(new Date().getTime() + (parseFloat(duration) * 60000));
if(_.has(dbot.modules, 'remind')) { if(_.has(dbot.modules, 'remind')) {
msTimeout = dbot.api.remind.parseTime(duration); msTimeout = dbot.api.remind.parseTime(duration);
event.reply(msTimeout); if(!msTimeout) {
return event.reply('Invalid time. Remember you must give e.g. 5m now.');
}
duration = duration.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds'); duration = duration.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds');
} else { } else {
duration += ' minutes'; duration += ' minutes';
@ -176,6 +178,9 @@ var commands = function(dbot) {
var msTimeout = new Date(new Date().getTime() + (parseFloat(timeout) * 3600000)); var msTimeout = new Date(new Date().getTime() + (parseFloat(timeout) * 3600000));
if(_.has(dbot.modules, 'remind')) { if(_.has(dbot.modules, 'remind')) {
msTimeout = dbot.api.remind.parseTime(timeout); msTimeout = dbot.api.remind.parseTime(timeout);
if(!msTimeout) {
return event.reply('Invalid time. Remember you must give e.g. 5m now.');
}
timeout = timeout.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds'); timeout = timeout.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds');
} else { } else {
timeout += ' hours'; timeout += ' hours';

View File

@ -15,7 +15,6 @@ var remind = function(dbot) {
var now = Date.now(); var now = Date.now();
var datesplits = time.match(/[0-9]+[dhms]/g); var datesplits = time.match(/[0-9]+[dhms]/g);
if(datesplits == null) { if(datesplits == null) {
event.reply("The time parameter was not a valid time mah boy, it was "+time);
return; return;
} }
var timeinseconds = 0; var timeinseconds = 0;
@ -43,6 +42,9 @@ var remind = function(dbot) {
}.bind(this), }.bind(this),
'doReminder': function(event,user,time,message) { 'doReminder': function(event,user,time,message) {
var then = this.api.parseTime(time); var then = this.api.parseTime(time);
if(!then) {
return event.reply("The time parameter was not a valid time mah boy, it was "+time);
}
if(dbot.config.debugMode) if(dbot.config.debugMode)
event.reply("The timer will be at "+then); event.reply("The timer will be at "+then);