From 6c7da7478321aaa30e432eaecd684c20fd298c27 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Sun, 12 Jan 2020 00:44:17 -0600 Subject: [PATCH 1/3] Log errors when they occur but are not caught --- src/main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index c9fd810..d13cae1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ // // main.ts // -// Written by: Tyler Akins (2020/01/06 - 2020/01/07) +// Written by: Tyler Akins (2020/01/06 - 2020/01/11) // @@ -10,7 +10,9 @@ import { START_BOT } from "./Twitch" const MAIN = async () => { - START_BOT(); + START_BOT().catch( + (err) => {console.error(err);} + ); }; From 7933b54a8bfc1b626b9ed5a388c2e8ecc7a8c4f7 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Sun, 19 Jan 2020 00:07:23 -0600 Subject: [PATCH 2/3] Add message links for foreshadowing --- foreshadowing.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 foreshadowing.txt diff --git a/foreshadowing.txt b/foreshadowing.txt new file mode 100644 index 0000000..962fe31 --- /dev/null +++ b/foreshadowing.txt @@ -0,0 +1 @@ +https://discordapp.com/channels/588912193345683486/588912193345683488/668334714918010890 From fe5221ed38a769232596e95ec7a8bc56faa42b18 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Sun, 19 Jan 2020 00:29:20 -0600 Subject: [PATCH 3/3] Add code to check for the max bits on each donation --- src/Twitch.ts | 24 +++++++++++++++++++----- src/types.d.ts | 5 +++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Twitch.ts b/src/Twitch.ts index cdab27c..1bc9e43 100644 --- a/src/Twitch.ts +++ b/src/Twitch.ts @@ -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] }; }; }; diff --git a/src/types.d.ts b/src/types.d.ts index 7d8e33c..a059b90 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -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[]; }; } \ No newline at end of file