mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 01:57:54 +02:00
Update npm
This commit is contained in:
+15
-3
@@ -26,6 +26,18 @@ module.exports = class NPMCommand extends Command {
|
|||||||
async run(msg, { query }) {
|
async run(msg, { query }) {
|
||||||
try {
|
try {
|
||||||
const { body } = await snekfetch.get(`https://registry.npmjs.com/${query}`);
|
const { body } = await snekfetch.get(`https://registry.npmjs.com/${query}`);
|
||||||
|
let maintainers = body.maintainers.map(user => user.name);
|
||||||
|
if (maintainers.length > 10) {
|
||||||
|
const len = maintainers.length - 10;
|
||||||
|
maintainers = maintainers.slice(0, 10);
|
||||||
|
maintainers.push(`...${len} more.`);
|
||||||
|
}
|
||||||
|
let dependencies = Object.keys(body.dependencies);
|
||||||
|
if (dependencies.length && dependencies.length > 10) {
|
||||||
|
const len = dependencies.length - 10;
|
||||||
|
dependencies = dependencies.slice(0, 10);
|
||||||
|
dependencies.push(`...${len} more.`);
|
||||||
|
}
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xCB0000)
|
.setColor(0xCB0000)
|
||||||
.setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png')
|
.setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png')
|
||||||
@@ -44,10 +56,10 @@ module.exports = class NPMCommand extends Command {
|
|||||||
new Date(body.time.modified).toDateString(), true)
|
new Date(body.time.modified).toDateString(), true)
|
||||||
.addField('❯ Main File',
|
.addField('❯ Main File',
|
||||||
body.versions[body['dist-tags'].latest].main, true)
|
body.versions[body['dist-tags'].latest].main, true)
|
||||||
.addField('❯ Keywords',
|
.addField('❯ Dependencies',
|
||||||
body.keywords && body.keywords.length ? shorten(body.keywords.join(', '), 1000) : 'None')
|
dependencies.length ? dependencies.join(', ') : 'None')
|
||||||
.addField('❯ Maintainers',
|
.addField('❯ Maintainers',
|
||||||
shorten(body.maintainers.map(user => user.name).join(', '), 1000));
|
maintainers.join(', '));
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 404) return msg.say('Could not find any results.');
|
if (err.status === 404) return msg.say('Could not find any results.');
|
||||||
|
|||||||
Reference in New Issue
Block a user