Play video when losing and gaining

This commit is contained in:
Wizzard 2024-03-02 18:58:18 -05:00
parent 8c5ee1faf2
commit 47ae231370
1 changed files with 14 additions and 7 deletions

21
main.js
View File

@ -104,7 +104,10 @@ function calculateProfitStatus(tokenData) {
const updateStatsMessage = async (tokenData) => { const updateStatsMessage = async (tokenData) => {
const statsChannel = await discordClient.channels.fetch(statsChannelId); const statsChannel = await discordClient.channels.fetch(statsChannelId);
if (!statsChannel) return; if (!statsChannel) {
console.log("Stats channel not found.");
return;
}
if (statsMessageId) { if (statsMessageId) {
try { try {
@ -216,13 +219,14 @@ const setSourceVisibility = (sourceName, visible) => {
ws.send(JSON.stringify(message)); ws.send(JSON.stringify(message));
}; };
const updateOBSTextVisibility = (makingMoney) => { const updateOBSTextVisibility = () => {
if (obsVisibilityState.makingMoney !== makingMoney) { const makingMoney = obsVisibilityState.makingMoney;
setSourceVisibility("TextGreen", makingMoney);
setSourceVisibility("TextRed", !makingMoney);
obsVisibilityState.makingMoney = makingMoney; setSourceVisibility("TextGreen", makingMoney);
} setSourceVisibility("TextRed", !makingMoney);
setSourceVisibility("Making", makingMoney);
setSourceVisibility("Losing", !makingMoney);
}; };
const checkStatusAndUpdateOBS = async () => { const checkStatusAndUpdateOBS = async () => {
@ -241,6 +245,8 @@ const checkStatusAndUpdateOBS = async () => {
priceChange: pair.priceChange.m5 priceChange: pair.priceChange.m5
}; };
obsVisibilityState.makingMoney = tokenData.profitStatus;
const priceFormatted = tokenData.price ? `$${parseFloat(tokenData.price).toFixed(8)}` : 'N/A'; const priceFormatted = tokenData.price ? `$${parseFloat(tokenData.price).toFixed(8)}` : 'N/A';
console.log(`Price Change (Last 5 Minutes): ${pair.priceChange.m5}%`); console.log(`Price Change (Last 5 Minutes): ${pair.priceChange.m5}%`);
@ -250,6 +256,7 @@ const checkStatusAndUpdateOBS = async () => {
setSourceVisibility("TextRed", !tokenData.profitStatus); setSourceVisibility("TextRed", !tokenData.profitStatus);
updateStatsMessage(tokenData); updateStatsMessage(tokenData);
updateOBSTextVisibility();
} else { } else {
console.log('No pairs data found for the token address.'); console.log('No pairs data found for the token address.');
} }