Search using a keyword. DISCORDJS JSON

Hello all, today I need some help with a search command!

I want to grab a name and waifuURL when someone specifys a specific keyword(The waifus name).
This is how the json is formatted:

    "waifuID": {
        "1": {
            "names": "Megumin",
            "img_url": "",
            "claims": "#1"
        "2": {
            "names": "Mai Sakurajima",
            "img_url": "",
            "claims": "#2"
        "3": {
            "names": "Zero Two",
            "img_url": "",
            "claims": "#3"

I want to be able to do !search and it would give the image url + the name of the waifu.
Input: !search Zero Two


Zero Two


Input: !search Megumin



(These responses are in an embed)

Thats the gist of it, thanks!

Are these stored in a database? If so, you can use something like

var search = message.slice.whatever.whatever
col.find({"names"}: search }).toArray.then(x => message.send "x")
//please don't copy this, it's absolutely terrible 

If this is a local JSON file, check out this link:

It’ll hopefully give you some ideas to solve your problem.

Good luck with this bot! I really admire people who can build discord bots because I was never able to do it, haha.

Thanks so much!

1 Like

If you don’t mind, could you mark my response as “solution” ?


I’ve found a way better way to do this.

  .find(value => value.names === "Zero Two").img_url)

(The value of obj is the actual JSON database.)