gaber-elsayed

package info

Mar 6th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. if(!hero) {
  2. hero = client;
  3. }
  4.  
  5. hero.on('message',async message => {
  6. if(message.author.bot || message.channel.type === 'dm') return;
  7. let args = message.content.split(" ").slice(1);
  8. let command = message.content.split(" ")[0];
  9. let request = require('snekfetch');
  10. if(command === `!npm`) {
  11. // https://www.npmjs.com/package/snekfetch
  12. if(!args[0]) return message.channel.send(`- **Specify an arg to search for in npmjs.com.**`);
  13. let url = args.includes(" ") ? args.replace(" ", "-") : args;
  14. url = `https://registry.npmjs.com/${url[0].toLowerCase()}`;
  15. console.log(url);
  16.  
  17. request.get(url).then(r => {
  18. message.channel.send(new RichEmbed()
  19. .setAuthor(message.author.username, message.author.avatarURL)
  20. .setThumbnail("https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png")
  21. .setTitle(args[0])
  22. .setColor("#000")
  23. .addField("» **Version**", `- ${r.body['dist-tags'].latest}`, true)
  24. .addField("» **License**", `- ${r.body.license}`, true)
  25. .addField("» **Creator**", `- ${r.body.author.name}`, true)
  26. .addField("» **Homepage**", `- [\`Click Here\`](${r.body.homepage})`, true)
  27. .addField("» **Description**", `- ${r.body.description || "- Without description."}`, true)
  28. .addField("» **Contributors**", `- ${r.body.contributors ? r.body.contributors.map(r => r.name).join(', ') : "None"}`, true)
  29. .addField("» **Keyboards**", `- ${r.body.keywords ? r.body.keywords.map(r => r).join(', ') : "None"}`, true));
  30. })
  31. .catch(e => {
  32. if(e) message.channel.send(`**- Couldn't find the package ${args[0]}**`);
  33. if(e) console.log(e.message);
  34. });
  35. }
  36. });
Add Comment
Please, Sign In to add comment