【发布时间】:2019-05-08 14:07:51
【问题描述】:
我想提取我的 .json 文件的数据,并按给定的名称在不和谐频道过滤中显示它。
在这种情况下,msg 变量包含我要搜索的名称。
var msg;
if (message.content.startsWith(prefix + prefix)) {
msg = message.content;
message.channel.send(msg.substring(2)); //this is just for testing
}
现在有了这个名字,我不知道如何在我的 .json 文件中搜索并提取数据。 这是我的 .json 文件的一部分
{
"ID": "1",
"Nombre": "luffy caca",
"Tipo": "str",
"Clase principal": "fighter"
},
{
"ID": "2",
"Nombre": "luffy manco",
"Tipo": "int",
"Clase principal": "slasher"
},
{
"ID": "3",
"Nombre": "luffy g2",
"Tipo": "str",
"Clase principal": "driven",
"Clase secundaria": "slasher"
}
所以我想在我的msg 变量上获得名称“luffy g2”时提取“ID:3”的数据。
【问题讨论】:
标签: javascript json bots discord