From b7075b1f2ca550c67c61ffad551117b147f491e0 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Fri, 24 Mar 2017 17:25:40 +0000 Subject: [PATCH] Remind Command Beta --- commands/botinfo/info.js | 2 +- commands/random/remind.js | 33 +++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 commands/random/remind.js diff --git a/commands/botinfo/info.js b/commands/botinfo/info.js index 49de9b2f..d3b2a432 100644 --- a/commands/botinfo/info.js +++ b/commands/botinfo/info.js @@ -59,7 +59,7 @@ module.exports = class InfoCommand extends commando.Command { .addField('Modules', "[cleverbot-node](https://github.com/fojas/cleverbot-node), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [google-translate-api](https://github.com/matheuss/google-translate-api), [urban](https://github.com/mvrilo/urban), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [yahoo-weather](https://github.com/mamal72/node-yahoo-weather), [imdb-api](https://github.com/worr/node-imdb-api), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [morse](https://github.com/ecto/morse)") .addField('Utility Modules', - "[superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [opusscript](https://github.com/abalabahaha/opusscript), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/)") + "[superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [opusscript](https://github.com/abalabahaha/opusscript), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/), [sherlockjs](https://github.com/maytis/sherlockjs)") .addField('APIs', "[Cleverbot API](https://www.cleverbot.com/api/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices API](http://docs.yugiohprices.apiary.io/#), [YouTube Data API](https://developers.google.com/youtube/v3/), [Yoda Speak API](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots API](https://bots.discord.pw/api), [Today in History API](http://history.muffinlabs.com/#api), [jService API](http://jservice.io/)") .addField('Other Credit', diff --git a/commands/random/remind.js b/commands/random/remind.js new file mode 100644 index 00000000..4298df5d --- /dev/null +++ b/commands/random/remind.js @@ -0,0 +1,33 @@ +const commando = require('discord.js-commando'); +const moment = require('moment'); +const sherlock = require('Sherlock'); + +module.exports = class RemindCommand extends commando.Command { + constructor(Client) { + super(Client, { + name: 'remind', + aliases: [ + 'remindme' + ], + group: 'random', + memberName: 'remind', + description: 'Reminds you of something at a certain time. (;remind Eat Food tomorrow)', + examples: [';remind Eat Food tomorrow'] + }); + } + + async run(message) { + if (message.channel.type !== 'dm') { + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + } + console.log(`[Command] ${message.content}`); + let remindMe = message.content.split(" ").slice(1).join(" "); + let remindTime = sherlock.parse(remindMe); + let time = remindTime.startDate.getTime() - Date.now(); + let preRemind = await message.channel.send(`I will remind you '${remindTime.eventTitle}' ${moment().add(time, 'ms').fromNow()}.`); + const remindMessage = await new Promise(resolve => { + setTimeout(() => resolve(message.channel.send(`${message.author} you wanted me to remind you of: '${remindTime.eventTitle}'`)), time); + }); + return [preRemind, remindMessage]; + } +}; diff --git a/package.json b/package.json index 03642d97..29a28079 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "opusscript": "0.0.3", "pirate-speak": "^1.0.1", "roman-numeral-converter-mmxvi": "^1.0.5", + "sherlockjs": "^0.0.9", "string-to-binary": "^0.1.2", "superagent": "^3.5.1", "urban": "^0.3.1",