0
0
Fork 0

Refactor to use the new database structure

This commit is contained in:
Oliver-Akins 2021-08-29 15:15:36 -06:00
parent f1586efc9e
commit 4d066aed41

View file

@ -12,7 +12,7 @@ export default {
let wh = db[gID].webhook; let wh = db[gID].webhook;
// Create the very first quote bracket // Create the very first quote bracket
let quotes: string[]; let quotes: quote[];
if (!db[gID].bracket.msg) { if (!db[gID].bracket.msg) {
quotes = await getQuote(gID, config.guilds[gID].quote_max); quotes = await getQuote(gID, config.guilds[gID].quote_max);
} else { } else {
@ -24,18 +24,15 @@ export default {
}); });
let pastBrackets = await loadHistory(gID); let pastBrackets = await loadHistory(gID);
pastBrackets.push({ pastBrackets.push(db[gID].bracket.quotes);
quotes: db[gID].bracket.quotes,
votes: db[gID].bracket.votes,
});
saveHistory(gID, pastBrackets); saveHistory(gID, pastBrackets);
// Calculate the winners from the previous bracket // Calculate the winners from the previous bracket
let r = await request.server.inject({ let r = await request.server.inject({
url: `/${gID}/bracket/winners`, url: `/${gID}/bracket/winners`,
auth: request.auth, auth: request.auth,
});; });
var data = JSON.parse(r.payload); let data = JSON.parse(r.payload);
var winner_count = data.count; var winner_count = data.count;
// Check if we are getting rid of all winners // Check if we are getting rid of all winners