From 37c9eb32ef3ac8d0f02659b7a46da8d32869ba9d Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 23 Apr 2017 02:23:49 +0000 Subject: [PATCH] LMGTFY Command --- commands/search/lmgtfy.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 commands/search/lmgtfy.js diff --git a/commands/search/lmgtfy.js b/commands/search/lmgtfy.js new file mode 100644 index 00000000..e0ea5feb --- /dev/null +++ b/commands/search/lmgtfy.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class LMGTFYCommand extends Command { + constructor(client) { + super(client, { + name: 'lmgtfy', + group: 'search', + memberName: 'lmgtfy', + description: 'Responds with a LMGTFY link. (x;lmgtfy How to Internet)', + examples: ['x;lmgtfy How to Internet'], + args: [{ + key: 'query', + prompt: 'What would you like to the link to search for?', + type: 'string', + parse: text => { + return encodeURIComponent(text); + } + }] + }); + } + + run(message, args) { + if (message.channel.type !== 'dm') { + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + } + const { query } = args; + return message.say(`http://lmgtfy.com/?iie=1&q=${query}`); + } +};