diff --git a/server/src/constants.ts b/server/src/constants.ts index 8078a5e..49a69d2 100644 --- a/server/src/constants.ts +++ b/server/src/constants.ts @@ -1,11 +1,12 @@ -export var BRACKET_DATA = { +export var BRACKET_DATA: bracket_data = { msg: "", quotes: [], - votes: {}, users: {}, + channel: "", }; -export var CHANNEL_DATA = { +export var CHANNEL_DATA: channel_data = { + version: 2, webhook: { token: "", id: "", diff --git a/server/src/endpoints/management/create_bracket.ts b/server/src/endpoints/management/create_bracket.ts index 22a17ba..79673ea 100644 --- a/server/src/endpoints/management/create_bracket.ts +++ b/server/src/endpoints/management/create_bracket.ts @@ -64,12 +64,10 @@ export default { auth: request.auth, }); let data = JSON.parse(r.payload); - var winner_count = data.count; // Check if we are getting rid of all winners if (data.eliminate_all) { quotes = []; - winner_count = 0; } else { quotes = data.winners; }; @@ -105,11 +103,11 @@ export default { type: 3, custom_id: `quote`, placeholder: `Choose Your Favourite Quote`, - options: quotes.map((_, i) => { + options: quotes.map((quote, i) => { return { label: `Quote ${i + 1}`, value: i, - emoji: i < winner_count ? { + emoji: quote.win_streak > 0 ? { name: `👑` } : null } @@ -136,7 +134,7 @@ export default { components: [], }; - if (extra_buttons.includes(`historyLink`)) { + if (extra_buttons.includes(`historyLink`) && config.server.history_site_base) { actionRow.components.push(historyLinkButton(gID)); }; diff --git a/server/src/types/database.d.ts b/server/src/types/database.d.ts index 9b249bb..e4f2323 100644 --- a/server/src/types/database.d.ts +++ b/server/src/types/database.d.ts @@ -12,14 +12,17 @@ interface bracket_data { users: { [index: string]: number }; } +interface channel_data { + version: 2, + webhook: { + id: string; + token: string; + }; + bracket: bracket_data; +} + interface database { - [index: string]: { - webhook: { - id: string; - token: string; - }; - bracket: bracket_data; - } + [index: string]: channel_data; } interface bracket_history {