mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 21:40:51 +02:00
NPM Command
This commit is contained in:
@@ -41,7 +41,7 @@ module.exports = class BotSearchCommand extends Command {
|
|||||||
body.prefix, true);
|
body.prefix, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} 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;
|
else throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
<li>Konachan</li>
|
<li>Konachan</li>
|
||||||
<li>Google Maps</li>
|
<li>Google Maps</li>
|
||||||
<li>Neopets</li>
|
<li>Neopets</li>
|
||||||
|
<li>NPM</li>
|
||||||
<li>osu!</li>
|
<li>osu!</li>
|
||||||
<li>Recipe Puppy</li>
|
<li>Recipe Puppy</li>
|
||||||
<li>Rule34</li>
|
<li>Rule34</li>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
<li>Konachan</li>
|
<li>Konachan</li>
|
||||||
<li>Google Maps</li>
|
<li>Google Maps</li>
|
||||||
<li>Neopets</li>
|
<li>Neopets</li>
|
||||||
|
<li>NPM</li>
|
||||||
<li>osu!</li>
|
<li>osu!</li>
|
||||||
<li>Recipe Puppy</li>
|
<li>Recipe Puppy</li>
|
||||||
<li>Rule34</li>
|
<li>Rule34</li>
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "27.3.2",
|
"version": "27.4.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user