From 58307fdd4c04bf26f398bbc3970868b454694a8e Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Thu, 23 Apr 2020 20:07:07 -0600 Subject: [PATCH] Add system to output HTML --- src/docs.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/docs.ts diff --git a/src/docs.ts b/src/docs.ts new file mode 100644 index 0000000..7986b27 --- /dev/null +++ b/src/docs.ts @@ -0,0 +1,43 @@ +import { DISCORD_CDN_BASE } from "./config"; +import * as fs from "fs"; + + +export const ADD_TO_DOCS = (msg: msg_meta, won: bracket_result) => { + let addition_indicator: string = ``; + let split_str: string = ` - **`; + let result: string; + + switch (won) { + case "NO_DATA": + case "TIE": + result = won; + break; + default: + result = `` + break; + }; + + let docstring_to_add: string = `
+
+ Winner: ${result} +

+ + +
+ ${msg.quote_a.value.split(split_str, 2)[1].slice(0, -2)} +
+

+ + +
+ ${msg.quote_b.value.split(split_str, 2)[1].slice(0, -2)} +
+
+ ${addition_indicator}`; + + let docs: string = fs.readFileSync(`./docs/index.html`, `utf8`); + console.log(docs) + docs = docs.replace(``, `${docstring_to_add}`); + console.log(docs); + fs.writeFileSync(`./docs/index.html`, `${docs}`); +} \ No newline at end of file