MDN Command

This commit is contained in:
Daniel Odendahl Jr
2017-09-14 00:41:14 +00:00
parent e88cfd7fc4
commit f24d09ac41
3 changed files with 44 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class MDNCommand extends Command {
constructor(client) {
super(client, {
name: 'mdn',
aliases: ['mozilla-developer-network'],
group: 'search',
memberName: 'mdn',
description: 'Searches MDN for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What article would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
try {
const { body } = await snekfetch
.get('https://developer.mozilla.org/en-US/search.json')
.query({ q: query });
if (!body.documents.length) return msg.say('Could not find any results.');
const embed = new MessageEmbed()
.setColor(0x066FAD)
.setAuthor('MDN', 'https://i.imgur.com/ClMfs9l.png')
.setURL(body.documents[0].url)
.setTitle(body.documents[0].title)
.setDescription(body.documents[0].excerpt);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1
View File
@@ -7,6 +7,7 @@ module.exports = class OsuCommand extends Command {
constructor(client) {
super(client, {
name: 'osu',
aliases: ['osu-user'],
group: 'search',
memberName: 'osu',
description: 'Searches osu! usernames for your query.',
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "38.7.3",
"version": "38.8.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {