0

I try to make a discord bot and i want to implement a voice call soundboard wich can play mp3 files from users. To store these files i need some information about the file. When its finished you should be able to play the files with a command like !sound play test. My question is: How can i search my JSON file after the Value key?

{       
    "test":{
        "owner":"some-id",
        "file":"mathemannsong.mp3",
        "stats":{
            "played": 0
        }
    },
    "test2":{
        "owner":"some-id",
        "file":"random.mp3",
        "stats":{
            "played": 5
        }
    }
}

This is my JSON file.

I want to search it like this:

cosnt file = require(".file.json")
const name = "test";
const owner = file.name.owner

I know why this dosn`t work.

1 Answers1

0

You can try import statement like below

Import * as file from 'file.json'
owner = file.name.owner
mathu mitha
  • 306
  • 2
  • 6