Skip to content

Commit

Permalink
Attempt to fix GAwesomeBot#524
Browse files Browse the repository at this point in the history
Signed-off-by: sohamg <[email protected]>
  • Loading branch information
SohamG committed Sep 21, 2019
1 parent b5712fd commit 1b773d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Configurations/config.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module.exports = {
* These last values can remain untouched.
*/
moment_date_format: "ddd MMMM Do YYYY [at] H:mm:ss",
max_reminder_time: "3 months", // time in parse-duration compatible format
voteTriggers: [
" +!",
" +1",
Expand Down
4 changes: 3 additions & 1 deletion Modules/MessageUtils/ReminderParser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { SetReminder } = require("../Utils/");
const parseDuration = require("parse-duration");
const { ObjectID } = require("mongodb");
const maxReminderTime = require("../../Configurations/config").max_reminder_time;

// Set a reminder from a remindme command suffix
module.exports = async (client, userDocument, userQueryDocument, str) => {
Expand All @@ -15,7 +16,8 @@ module.exports = async (client, userDocument, userQueryDocument, str) => {
remind = str.indexOf("to ") === 0 ? str.substring(3, str.toLowerCase().lastIndexOf(" in ")) : str.substring(0, str.toLowerCase().lastIndexOf(" in "));
}
const time = parseDuration(timestr);
if (time > 0 && remind) {
const maxTime = parse(maxReminderTime);
if (time > 0 && time < maxReminderTime && remind) {
userQueryDocument.push("reminders", {
_id: ObjectID().toString(),
name: remind,
Expand Down

0 comments on commit 1b773d6

Please sign in to comment.