From 0c802745de293293cd48e2efffed63705e3a0281 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 5 Nov 2017 15:36:01 +0000 Subject: [PATCH] Update mdn --- commands/search/mdn.js | 12 ++++++++---- package.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/commands/search/mdn.js b/commands/search/mdn.js index d7dc8d3f..36f14086 100644 --- a/commands/search/mdn.js +++ b/commands/search/mdn.js @@ -1,7 +1,6 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { shorten } = require('../../util/Util'); module.exports = class MDNCommand extends Command { constructor(client) { @@ -16,7 +15,8 @@ module.exports = class MDNCommand extends Command { { key: 'query', prompt: 'What article would you like to search for?', - type: 'string' + type: 'string', + parse: query => query.replace(/#/g, '.prototype.') } ] }); @@ -26,7 +26,11 @@ module.exports = class MDNCommand extends Command { try { const { body } = await snekfetch .get('https://developer.mozilla.org/en-US/search.json') - .query({ q: query }); + .query({ + q: query, + locale: 'en-US', + highlight: false + }); if (!body.documents.length) return msg.say('Could not find any results.'); const data = body.documents[0]; const embed = new MessageEmbed() @@ -34,7 +38,7 @@ module.exports = class MDNCommand extends Command { .setAuthor('MDN', 'https://i.imgur.com/DFGXabG.png') .setURL(data.url) .setTitle(data.title) - .setDescription(shorten(data.excerpt)); + .setDescription(data.excerpt); return msg.embed(embed); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/package.json b/package.json index 7854a6e1..8a29ab98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "51.4.2", + "version": "51.4.3", "description": "Your personal server companion.", "main": "XiaoBot.js", "scripts": {