【发布时间】:2021-05-14 04:14:59
【问题描述】:
我目前正在开发一个跟踪 Steam 价格并将其发送到聊天的 Discord 机器人。我为它编写了这段代码:
setInterval(() => {
const currentDate = new Date();
var yourchannel = client.channels.cache.get('[CHANNEL ID]');
fetch('https://steamcommunity.com/market/priceoverview/?appid=730&market_hash_name=Operation%20Breakout%20Weapon%20Case¤cy=6', )
.then(res => res.text())
.then(text => yourchannel.send(`Breakout case price on ${currentDate.toLocaleDateString(`pl-PL`)} is ${text}`))
}, 1000 * 60 * 60 * 24);
});
我希望我的机器人发送消息 “[date] 的分包价格为 [price]。” 例如 “2021 年 2 月 10 日的分包价格为 5.94zł” em>,但它会发送这个:
Breakout case price on 10.02.2021 is {"success":true,"lowest_price":"5,92zł","volume":"13,807","median_price":"6,01zł"}
【问题讨论】:
-
...`是 ${text.lowest_price}``
标签: javascript node.js discord.js node-fetch