Get Movie or Series Information Using IMDB API With discord.js v12 1

Get Movie or Series Information Using IMDB API With discord.js v12

Well everyone likes movies and web series, what if you can make a discord command on it like you can search about any your Favourite movie and series. On that point API comes to use , if you do not know what is API then google it. SO, we will be using IMDB api here and before we go any further make sure you install imdb-api by using npm install imdb-api

i will be using my command handler and if you do not know how to create command handler than you should check this post – COMMAND HANDLER

const discord = require("discord.js");
const imdb = require("imdb-api");

module.exports = {
name: "imdb",
  description: "Get the information about series and movie",
  category: "info",
  usage: "imdb <name>",
  run: async (client, message, args, color) => {

}
    }

you will be using async function as we will use await, first we will add argument error

 if(!args.length) {
      return message.channel.send("Please give the name of movie or series")
    }

Now we will be getting information about the given name by author by using API

 const imob = new imdb.Client({apiKey: "5e36f0db"}) //You need to paste you imdb api
 let movie = await imob.get({'name': args.join(" ")})

We will be sending embed message with full of information

 let embed = new discord.MessageEmbed()
    .setTitle(movie.title)
    .setColor("#ff2050")
    .setThumbnail(movie.poster)
    .setDescription(movie.plot)
    .setFooter(`Ratings: ${movie.rating}`)
    .addField("Country", movie.country, true)
    .addField("Languages", movie.languages, true)
    .addField("Type", movie.type, true);
    
    
    message.channel.send(embed)

here we are done , as you have seen that its very easy to intract with api

Get Movie or Series Information Using IMDB API With discord.js v12 2

Table of Contents

Resulting Code

Here is the result code of whole post – here

Leave a Reply

Your email address will not be published. Required fields are marked *