1 回答

TA貢獻1824條經(jīng)驗 獲得超8個贊
這是因為返回的數(shù)據(jù)是一個對象數(shù)組。如果您想將它們?nèi)孔鳛橄l(fā)送,您可以迭代它們。如果您想將它們一一發(fā)送,可以使用以下方法:
if (command === 'inv') {
const getInv = async () => {
const response = await axios.get(
'https://inventory.roblox.com/v1/users/1417341214/assets/collectibles?sortOrder=Asc&limit=100',
);
return response.data;
};
const invValue = await getInv();
let total = 0;
invValue.data.forEach((item) => {
message.channel.send(`${item.name} \n ${item.recentAveragePrice}`);
total += item.recentAveragePrice;
});
message.channel.send(`Total average price: ${total}`);
}
結果:
添加回答
舉報