Add six hour tracker and fix one day tracker
This commit is contained in:
parent
faff35fa90
commit
3d21de9bf1
12
main.js
12
main.js
|
@ -76,6 +76,7 @@ function immediatePriceCheckAndAnnounce() {
|
|||
let oneMinChange = { percent: 0, dollar: 0 };
|
||||
let fiveMinChange = { percent: 0, dollar: 0 };
|
||||
let oneHourChange = { percent: 0, dollar: 0 };
|
||||
let sixHourChange = { percent: 0, dollar: 0 }
|
||||
let oneDayChange = { percent: 0, dollar: 0 };
|
||||
|
||||
const now = Date.now();
|
||||
|
@ -111,10 +112,14 @@ function immediatePriceCheckAndAnnounce() {
|
|||
oneDayChange.dollar = latestPrice - oneDayAgoPrice;
|
||||
}
|
||||
|
||||
return { oneMinChange, fiveMinChange, oneHourChange, oneDayChange };
|
||||
if (priceHistory.prices.length >= 360) {
|
||||
const sixHourAgoPrice = parseFloat(findPriceAgo(360).price);
|
||||
sixHourChange.percent = ((latestPrice - sixHourAgoPrice) / sixHourAgoPrice) * 100;
|
||||
sixHourChange.dollar = latestPrice - sixHourAgoPrice;
|
||||
}
|
||||
|
||||
const { oneMinChange, fiveMinChange, oneHourChange, oneDayChange } = calculateChanges();
|
||||
return { oneMinChange, fiveMinChange, oneHourChange, sixHourChange, oneDayChange };
|
||||
}
|
||||
|
||||
async function sendNewPriceMessage(embed) {
|
||||
const sentMessage = await solanaPriceChannel.send({ embeds: [embed] });
|
||||
|
@ -132,7 +137,7 @@ async function sendNewPriceMessage(solanaPriceChannel, embed) {
|
|||
|
||||
async function checkPriceContinuously() {
|
||||
await fetchSolanaPriceAndUpdateHistory();
|
||||
const { oneMinChange, fiveMinChange, oneHourChange } = calculateChanges();
|
||||
const { oneMinChange, fiveMinChange, oneHourChange, sixHourChange, oneDayChange } = calculateChanges();
|
||||
|
||||
console.log(`Current Price: ${priceHistory.currentPrice}`);
|
||||
|
||||
|
@ -148,6 +153,7 @@ async function checkPriceContinuously() {
|
|||
{ name: '1 Minute Change', value: `${oneMinChange.percent.toFixed(2)}% (${oneMinChange.dollar.toFixed(2)} USD)`, inline: true },
|
||||
{ name: '5 Minute Change', value: `${fiveMinChange.percent.toFixed(2)}% (${fiveMinChange.dollar.toFixed(2)} USD)`, inline: true },
|
||||
{ name: '1 Hour Change', value: `${oneHourChange.percent.toFixed(2)}% (${oneHourChange.dollar.toFixed(2)} USD)`, inline: true },
|
||||
{ name: '6 Hour Change', value: `${sixHourChange.percent.toFixed(2)}% (${sixHourChange.dollar.toFixed(2)} USD)`, inline: true },
|
||||
{ name: '1 Day Change', value: `${oneDayChange.percent.toFixed(2)}% (${oneDayChange.dollar.toFixed(2)} USD)`, inline: true }
|
||||
])
|
||||
.setTimestamp()
|
||||
|
|
Loading…
Reference in New Issue