Add code to check for the max bits on each donation

This commit is contained in:
Tyler-A 2020-01-19 00:29:20 -06:00
parent 7933b54a8b
commit fe5221ed38
2 changed files with 22 additions and 7 deletions

View file

@ -1,7 +1,7 @@
//
// Twitch.ts
//
// Written by: Tyler Akins (2020/01/06 - 2020/01/09)
// Written by: Tyler Akins (2020/01/06 - 2020/01/18)
//
@ -72,9 +72,15 @@ export const START_BOT = async () => {
// Ensure the user is live
if (!response) {
data["offline"].total_bits += bits;
data["offline"].donations.push(bits);
data["offline"].donators.push(donator);
data.offline.total_bits += bits;
data.offline.donations.push(bits);
data.offline.donators.push(donator);
// Check if we have a new max
if (data.offline.max[1] < bits) {
data.offline.max[0] = donator;
data.offline.max[1] = bits;
};
} else {
// Data already exists
@ -88,6 +94,13 @@ export const START_BOT = async () => {
// Add the bits to the total and the array of donations
data[date].total_bits += bits;
data[date].donations.push(bits);
// Check if we have a new max
if (data[date].max[1] < bits) {
data[date].max[0] = donator;
data[date].max[1] = bits;
};
}
// Making new data point
@ -95,7 +108,8 @@ export const START_BOT = async () => {
data[date] = {
total_bits: bits,
donators: [donator],
donations: [bits]
donations: [bits],
max: [donator, bits]
};
};
};

5
src/types.d.ts vendored
View file

@ -1,14 +1,15 @@
//
// types.d.ts
//
// Written by: Tyler Akins (2020/01/06)
// Written by: Tyler Akins (2020/01/06 - 2020/01/18)
//
interface data {
[key: string]: {
max: [string, number];
donations: number[];
total_bits: number;
donators: string[];
donations: number[];
};
}