SHARE
TWEET

Untitled

n3k4a May 23rd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', async message => {
  2.     if (message.author.bot || message.channel.type === 'dm') return;
  3.     let args = message.content.split(" ").slice(1);
  4.     let command = message.content.split(" ")[0];
  5.     let request = require('snekfetch');
  6.     if (command === `-npm`) {
  7.         // https://www.npmjs.com/package/snekfetch
  8.         if (!args[0]) return message.channel.send(`**${f} | Specify an arg to search for in npmjs.com.**`);
  9.         let url = args.includes(" ") ? args.replace(" ", "-") : args;
  10.         url = `https://registry.npmjs.com/${url[0].toLowerCase()}`;
  11.         request.get(url).then(r => {
  12.                 message.channel.send(new Discord.RichEmbed()
  13.                     .setAuthor(message.author.username, message.author.avatarURL)
  14.                     .setThumbnail("https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png")
  15.                     .setTitle(`❯ \`${args[0]}\`.`)
  16.                     .setColor("#000")
  17.                     .addField("» **Version**", `- ${r.body['dist-tags'].latest}`, true)
  18.                     .addField("» **License**", `- ${r.body.license}`, true)
  19.                     .addField("» **Homepage**", `- [\`Click Here\`](${r.body.homepage})`, true)
  20.                     .addField("» **Description**", `- ${r.body.description || "- Without description."}`, true)
  21.                     .addField("» **Contributors**", `- ${r.body.contributors ? r.body.contributors.map(r => r.name).join(', ') : "None"}`, true)
  22.                     .addField("» **Keyboards**", `- ${r.body.keywords ? r.body.keywords.map(r => r).join(', ') : "None"}`, true));
  23.             })
  24.             .catch(e => {
  25.                 if (e) message.channel.send(`**${f} |  Couldn't find the package \`${args[0]}\` .**`);
  26.                 if (e) console.log(e.message);
  27.             });
  28.     }
  29. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top