Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!hero) {
- hero = client;
- }
- hero.on('message',async message => {
- if(message.author.bot || message.channel.type === 'dm') return;
- let args = message.content.split(" ").slice(1);
- let command = message.content.split(" ")[0];
- let request = require('snekfetch');
- if(command === `!npm`) {
- // https://www.npmjs.com/package/snekfetch
- if(!args[0]) return message.channel.send(`- **Specify an arg to search for in npmjs.com.**`);
- let url = args.includes(" ") ? args.replace(" ", "-") : args;
- url = `https://registry.npmjs.com/${url[0].toLowerCase()}`;
- console.log(url);
- request.get(url).then(r => {
- message.channel.send(new RichEmbed()
- .setAuthor(message.author.username, message.author.avatarURL)
- .setThumbnail("https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png")
- .setTitle(args[0])
- .setColor("#000")
- .addField("» **Version**", `- ${r.body['dist-tags'].latest}`, true)
- .addField("» **License**", `- ${r.body.license}`, true)
- .addField("» **Creator**", `- ${r.body.author.name}`, true)
- .addField("» **Homepage**", `- [\`Click Here\`](${r.body.homepage})`, true)
- .addField("» **Description**", `- ${r.body.description || "- Without description."}`, true)
- .addField("» **Contributors**", `- ${r.body.contributors ? r.body.contributors.map(r => r.name).join(', ') : "None"}`, true)
- .addField("» **Keyboards**", `- ${r.body.keywords ? r.body.keywords.map(r => r).join(', ') : "None"}`, true));
- })
- .catch(e => {
- if(e) message.channel.send(`**- Couldn't find the package ${args[0]}**`);
- if(e) console.log(e.message);
- });
- }
- });
Add Comment
Please, Sign In to add comment