0

I am using Discord API on Node JS.

I got a JSON array and I am trying to get the client output the corresponding value for what the user typed inside a json array.

Inside the client.js

let name = (arg[1])
message.author.send('Result: ' + data.name.desc + data.name.code)

Inside the JSON:

{
   "Server1": {
    "desc": "A Fun Place",
    "code": "9021da"
    },
   "Server2": {
    "desc": "A Chill Place",
    "code": "90a11d"
    }
}    

What I am trying to do is giving the user the desc and the code of the server that they type. (There are over 100 of these)

1 Answer 1

1

You have to use bracket notation:

message.author.send('Result: ' + data[name].desc + data[name].code)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.