NPM Command

This commit is contained in:
Daniel Odendahl Jr
2017-07-23 00:22:07 +00:00
parent 827c14fd55
commit 0c1f3fd2ca
5 changed files with 54 additions and 2 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ module.exports = class BotSearchCommand extends Command {
body.prefix, true);
return msg.embed(embed);
} catch (err) {
if (err.message === '404 Not Found') return msg.say('Bot Not Found.');
if (err.status === 404) return msg.say('Bot Not Found.');
else throw err;
}
}
+50
View File
@@ -0,0 +1,50 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class NPMCommand extends Command {
constructor(client) {
super(client, {
name: 'npm',
group: 'search',
memberName: 'npm',
description: 'Searches NPM for info on an NPM package.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What package do you want to get information for?',
type: 'string'
}
]
});
}
async run(msg, args) {
try {
const { query } = args;
const { body } = await snekfetch
.get(`https://registry.npmjs.com/${query}`);
const embed = new MessageEmbed()
.setColor(0xCB0000)
.setAuthor('NPM', 'https://i.imgur.com/BCODHXd.png')
.setTitle(body.name)
.setURL(`https://www.npmjs.com/package/${query}`)
.setDescription(body.description)
.addField(' Version',
body['dist-tags'].latest, true)
.addField(' License',
body.license, true)
.addField(' Author',
body.author.name, true)
.addField(' Keywords',
body.keywords.join(', '))
.addField(' Maintainers',
body.maintainers.map((user) => user.name).join(', '));
return msg.embed(embed);
} catch (err) {
if (err.status === 404) return msg.say('Not Found.');
else throw err;
}
}
};
+1
View File
@@ -47,6 +47,7 @@
<li>Konachan</li>
<li>Google Maps</li>
<li>Neopets</li>
<li>NPM</li>
<li>osu!</li>
<li>Recipe Puppy</li>
<li>Rule34</li>
+1
View File
@@ -44,6 +44,7 @@
<li>Konachan</li>
<li>Google Maps</li>
<li>Neopets</li>
<li>NPM</li>
<li>osu!</li>
<li>Recipe Puppy</li>
<li>Rule34</li>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "27.3.2",
"version": "27.4.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {