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