mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Added support for Fourthwall alerts
This commit is contained in:
+110
-3
@@ -243,9 +243,9 @@ client.on('Fourthwall.GiftDrawStarted', (response) => {
|
|||||||
FourthwallGiftDrawStarted(response.data);
|
FourthwallGiftDrawStarted(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('Fourthwall.GiftDrawEnd', (response) => {
|
client.on('Fourthwall.GiftDrawEnded', (response) => {
|
||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
FourthwallGiftDrawEnd(response.data);
|
FourthwallGiftDrawEnded(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -836,36 +836,126 @@ function FourthwallOrderPlaced(data) {
|
|||||||
if (!showFourthwallAlerts)
|
if (!showFourthwallAlerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let user = data.username;
|
||||||
|
const orderTotal = data.total;
|
||||||
|
const currency = data.currency;
|
||||||
|
const item = data.variants[0].name;
|
||||||
|
const itemsOrdered = data.variants.length;
|
||||||
|
|
||||||
|
let message = "";
|
||||||
|
|
||||||
|
// If there user did not provide a username, just say "Someone"
|
||||||
|
if (user == undefined)
|
||||||
|
user = "Someone"
|
||||||
|
|
||||||
|
// If the user ordered more than one item, write how many items they ordered
|
||||||
|
message += `${user} ordered ${item}`;
|
||||||
|
if (itemsOrdered > 1)
|
||||||
|
message += ` and ${itemsOrdered - 1} other item(s)!`
|
||||||
|
|
||||||
|
// If the user spent money, put the order total
|
||||||
|
if (orderTotal == 0)
|
||||||
|
message += ``;
|
||||||
|
else if (currency == "USD")
|
||||||
|
message += ` ($${orderTotal})`;
|
||||||
|
else
|
||||||
|
message += ` (${orderTotal} ${currency})`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
}
|
}
|
||||||
|
|
||||||
function FourthwallDonation(data) {
|
function FourthwallDonation(data) {
|
||||||
if (!showFourthwallAlerts)
|
if (!showFourthwallAlerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let user = data.username;
|
||||||
|
const amount = data.amount;
|
||||||
|
const currency = data.currency;
|
||||||
|
|
||||||
|
let message = "";
|
||||||
|
if (currency == "USD")
|
||||||
|
message = `${user} donated $${amount}`;
|
||||||
|
else
|
||||||
|
message = `${user} donated ${currency} ${amount}`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
}
|
}
|
||||||
|
|
||||||
function FourthwallSubscriptionPurchased(data) {
|
function FourthwallSubscriptionPurchased(data) {
|
||||||
if (!showFourthwallAlerts)
|
if (!showFourthwallAlerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let user = data.nickname;
|
||||||
|
const amount = data.amount;
|
||||||
|
const currency = data.currency;
|
||||||
|
|
||||||
|
let message = "";
|
||||||
|
if (currency == "USD")
|
||||||
|
message = `${user} subscribed $${amount}`;
|
||||||
|
else
|
||||||
|
message = `${user} donsubscribedated ${currency} ${amount}`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
}
|
}
|
||||||
|
|
||||||
function FourthwallGiftPurchase(data) {
|
function FourthwallGiftPurchase(data) {
|
||||||
if (!showFourthwallAlerts)
|
if (!showFourthwallAlerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let user = data.username;
|
||||||
|
const total = data.total;
|
||||||
|
const currency = data.currency;
|
||||||
|
const gifts = data.gifts.length;
|
||||||
|
const itemName = data.offer.name;
|
||||||
|
|
||||||
|
let message = "";
|
||||||
|
|
||||||
|
// If the user ordered more than one item, write how many items they ordered
|
||||||
|
message += `${user} gifted`;
|
||||||
|
|
||||||
|
// If there is more than one gifted item, display the number of gifts
|
||||||
|
if (gifts > 1)
|
||||||
|
message += ` ${gifts} x `;
|
||||||
|
|
||||||
|
// The name of the item to be given away
|
||||||
|
message += ` ${itemName}`;
|
||||||
|
|
||||||
|
// If the user spent money, put the order total
|
||||||
|
if (currency == "USD")
|
||||||
|
message += ` ($${total})`;
|
||||||
|
else
|
||||||
|
message += ` (${currency}${total})`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
}
|
}
|
||||||
|
|
||||||
function FourthwallGiftDrawStarted(data) {
|
function FourthwallGiftDrawStarted(data) {
|
||||||
if (!showFourthwallAlerts)
|
if (!showFourthwallAlerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const durationSeconds = data.durationSeconds;
|
||||||
|
const itemName = data.offer.name;
|
||||||
|
|
||||||
|
let message = "";
|
||||||
|
message += `${user} gifted`;
|
||||||
|
|
||||||
|
// If the user ordered more than one item, write how many items they ordered
|
||||||
|
message += `🎁 ${itemName} Giveaway! • Type !join in the next ${durationSeconds} seconds for your chance to win!`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
}
|
}
|
||||||
|
|
||||||
function FourthwallGiftDrawEnd(data) {
|
function FourthwallGiftDrawEnded(data) {
|
||||||
if (!showFourthwallAlerts)
|
if (!showFourthwallAlerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let message = `🥳 GIVEAWAY ENDED 🥳`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
|
|
||||||
|
message = `Congratulations ${GetWinnersList(data.gifts)}!`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'fourthwall');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1075,6 +1165,23 @@ function ShowAlert(message, background = null, duration = animationDuration) {
|
|||||||
}, duration); // Remove after 5 seconds
|
}, duration); // Remove after 5 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetWinnersList(gifts) {
|
||||||
|
const winners = gifts.map(gift => gift.winner);
|
||||||
|
const numWinners = winners.length;
|
||||||
|
|
||||||
|
if (numWinners === 0) {
|
||||||
|
return "";
|
||||||
|
} else if (numWinners === 1) {
|
||||||
|
return winners[0];
|
||||||
|
} else if (numWinners === 2) {
|
||||||
|
return `${winners[0]} and ${winners[1]}`;
|
||||||
|
} else {
|
||||||
|
const lastWinner = winners.pop();
|
||||||
|
const secondLastWinner = winners.pop();
|
||||||
|
return `${winners.join(", ")}, ${secondLastWinner} and ${lastWinner}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|||||||
@@ -242,19 +242,23 @@ li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.patreon {
|
.patreon {
|
||||||
background: linear-gradient(#c76633, #fd5e0a) !important;
|
background: linear-gradient(#c76633bf, #fd5e0abf) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kofi {
|
.kofi {
|
||||||
background: linear-gradient(#54c7ee, #08c2ff) !important;
|
background: linear-gradient(#54c7eebf, #08c2ffbf) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tipeeeStream {
|
.tipeeeStream {
|
||||||
background: linear-gradient(#120e23, #5d192a) !important;
|
background: linear-gradient(#120e23bf, #5d192abf) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fourthwall {
|
.fourthwall {
|
||||||
background: linear-gradient(#405eb3, #0d3cb9) !important;
|
background: linear-gradient(#466edbbf, #1c56f5bf) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blank {
|
||||||
|
background: #adadad00 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************/
|
/****************/
|
||||||
|
|||||||
@@ -1452,7 +1452,7 @@ function FourthwallDonation(data) {
|
|||||||
let contents = "";
|
let contents = "";
|
||||||
|
|
||||||
// If the user ordered more than one item, write how many items they ordered
|
// If the user ordered more than one item, write how many items they ordered
|
||||||
contents += `<span style="background: #0042ff; padding: 0px 0.5em">${user}</span> donated`;
|
contents += `${user} donated`;
|
||||||
|
|
||||||
// If the user spent money, put the order total
|
// If the user spent money, put the order total
|
||||||
if (currency == "USD")
|
if (currency == "USD")
|
||||||
@@ -1500,7 +1500,7 @@ function FourthwallSubscriptionPurchased(data) {
|
|||||||
let contents = "";
|
let contents = "";
|
||||||
|
|
||||||
// If the user ordered more than one item, write how many items they ordered
|
// If the user ordered more than one item, write how many items they ordered
|
||||||
contents += `<span style="background: #0042ff; padding: 0px 0.5em">${user}</span> subscribed`;
|
contents += `${user} subscribed`;
|
||||||
|
|
||||||
// If the user spent money, put the order total
|
// If the user spent money, put the order total
|
||||||
if (currency == "USD")
|
if (currency == "USD")
|
||||||
@@ -1605,7 +1605,7 @@ function FourthwallGiftDrawStarted(data) {
|
|||||||
contentDiv.classList.add('centerThatShitHomie');
|
contentDiv.classList.add('centerThatShitHomie');
|
||||||
|
|
||||||
// Set the text
|
// Set the text
|
||||||
let durationSeconds = data.durationSeconds;
|
const durationSeconds = data.durationSeconds;
|
||||||
const itemName = data.offer.name;
|
const itemName = data.offer.name;
|
||||||
|
|
||||||
let contents = "";
|
let contents = "";
|
||||||
@@ -1643,10 +1643,6 @@ function FourthwallGiftDrawEnded(data) {
|
|||||||
titleDiv.classList.add('centerThatShitHomie');
|
titleDiv.classList.add('centerThatShitHomie');
|
||||||
contentDiv.classList.add('centerThatShitHomie');
|
contentDiv.classList.add('centerThatShitHomie');
|
||||||
|
|
||||||
// Set the text
|
|
||||||
let durationSeconds = data.durationSeconds;
|
|
||||||
const itemName = data.offer.name;
|
|
||||||
|
|
||||||
let contents = "";
|
let contents = "";
|
||||||
|
|
||||||
// If the user ordered more than one item, write how many items they ordered
|
// If the user ordered more than one item, write how many items they ordered
|
||||||
|
|||||||
Reference in New Issue
Block a user