Update mdn

This commit is contained in:
Daniel Odendahl Jr
2017-11-05 15:36:01 +00:00
parent 2a82601523
commit 0c802745de
2 changed files with 9 additions and 5 deletions
+8 -4
View File
@@ -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!`);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "51.4.2",
"version": "51.4.3",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {