Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Discord API,无法从节点JS中的用户输入arg[1]从数组内的json数组获取数据_Node.js_Json_Discord - Fatal编程技术网

Node.js Discord API,无法从节点JS中的用户输入arg[1]从数组内的json数组获取数据

Node.js Discord API,无法从节点JS中的用户输入arg[1]从数组内的json数组获取数据,node.js,json,discord,Node.js,Json,Discord,我在节点JS上使用discordapi 我得到了一个JSON数组,我正试图让客户端输出用户在JSON数组中键入的内容的相应值 在client.js中 let name = (arg[1]) message.author.send('Result: ' + data.name.desc + data.name.code) 在JSON中: { "Server1": { "desc": "A Fun Place", &

我在节点JS上使用discordapi

我得到了一个JSON数组,我正试图让客户端输出用户在JSON数组中键入的内容的相应值

在client.js中

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

{
   "Server1": {
    "desc": "A Fun Place",
    "code": "9021da"
    },
   "Server2": {
    "desc": "A Chill Place",
    "code": "90a11d"
    }
}    
我想做的是给用户描述和他们输入的服务器代码。
(其中有100多个)

您必须使用括号表示法:

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