Advertisement
iiFireKingii

Imdb Command

Sep 1st, 2019
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. const qs = require('querystring');
  2. const fetch = require('node-fetch');
  3. client.on("message", message => {
  4. if(message.author.bot || message.channel.type === 'dm') return;
  5. let alias = message.content.split(" ")[0].substring(prefix.length);
  6. let args = message.content.split(" ");
  7. if(alias === 'film') {
  8. if(!args[1]) return;
  9. let query = qs.stringify({ s: args.slice(1).join(" ") });
  10. let queryString = `http://www.omdbapi.com/?apikey=7163cd9d&type=movie&${query}`;
  11. fetch(queryString)
  12. .then(res => res.json())
  13. .then(async res => {
  14. let search = res.Search;
  15. let director = res.Director
  16. request(`https://www.imdb.com/title/${search[0].imdbID}`, async function (error, response, body) {
  17. let story = body.split("<div class=\"summary_text\">")[1].toString().split("</div>")[0];
  18. let o = new Discord.RichEmbed();
  19. await o.setColor("#090303");
  20. await o.setThumbnail(search[0].Poster);
  21. await o.setTitle(`**» ${search[0].Title}**`);
  22. await o.setURL(`https://www.imdb.com/title/${search[0].imdbID}`);
  23. await o.addField("» Release", search[0].Year, true);
  24. await o.addField("» Story", story, true);
  25. await message.channel.send(o);
  26. });
  27. }).catch(e => {
  28. if(e) return message.channel.send(`**:x: | Couldn't get any results**`);
  29. });
  30. }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement