【发布时间】:2020-07-03 14:22:06
【问题描述】:
所以我一直在尝试在 Node.js 中制作 Discord Bot,我从外部 api 获取数据并使用 BOT 来显示数据,问题是当我调用该函数时,它会一一显示一条消息中的所有内容。 我想在一条消息中显示所有内容。
const token = 'my discord token is here';
const Discord = require('discord.js');
const axios = require('axios');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on('message', async msg => {
if (msg.content === '!inventario') {
let getInv = async () => {
let response = await axios.get('my api link where im getting the info is here')
let inventario = response.data
return inventario
}
let inventarioValue = await getInv ()
var inv = inventarioValue.total_inventory_count
msg.channel.send(`Total de Itens no inventário: ${inventarioValue.total_inventory_count} \nSkins:\n`);
for (var i=0;i<inv;i++)
{
var itens = inventarioValue.descriptions[i].market_name
msg.channel.send(itens);
}
}
});
client.login(token);
我想执行这个 inventarioValue.descriptions[i].market_name,然后在执行后显示完整结果而不是一一显示。
谢谢
【问题讨论】:
标签: arrays node.js json discord.js