I want to make a Discord meme bot using JavaScript [closed]

I have recently made a Python Discord bot and I want to built the same with JavaScript. I am totally new in this language and I don’t know how I will add the meme command in.

in the Python version, I used a website heroukuapp to get memes from subreddit.

Here’s how I made it in Python-

if message.content == 'Show me some memes':
            content = get("https://meme-api.herokuapp.com/gimme").text
            data = json.loads(content,)
            meme = discord.Embed(title=f"{data['title']}", Color = discord.Color.random()).set_image(url=f"{data['url']}")
            await message.channel.send("MEMEY.....MEMEY.....MEMEY......n")
            await message.channel.send(embed=meme)

I want to use the same website for displaying memes in the JS bot (in embeds form). I have tried many APIs and seen many videos, but still I ccouldnt use them.

Till now, this is what I have done in JavaScript-

case "Show me some memes":

Can anyone solve my query?

Thanks for viewing my post.


You may use got an Node.js based HTTPS request library to request the API and further parse the response and use the things you need from the body ( alternatives – node-fetch ( previously snekfetch – ESM module ))

Here’s an example:

const got = require("got");
const { MessageEmbed } = require("discord.js");
got("https://meme-api.herokuapp.com/gimme").then( (response) => {
const data = JSON.parse(response.body);
let meme = new MessageEmbed
message.channel.send({ content: "MEMEY..MEMEY...MEMEY...", embeds: [meme]});

This is specifically for discord.js v13 if you’re on any version that’s below 13 you may directly pass the embed object like so: