diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-27 14:46:20 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-27 21:40:40 +1100 |
commit | 8443d1da2dd7f1d235a3e77407f37214b9fd15f3 (patch) | |
tree | b941dddbaffe522572cc0377085b4b294fcc732b /scripts/changelog.js | |
parent | Make /stop route not ugly as hell (diff) | |
download | server-8443d1da2dd7f1d235a3e77407f37214b9fd15f3.tar.xz |
Added scripts for changelogs and removed premium references
Diffstat (limited to '')
-rw-r--r-- | scripts/changelog.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/changelog.js b/scripts/changelog.js new file mode 100644 index 00000000..412e6e0c --- /dev/null +++ b/scripts/changelog.js @@ -0,0 +1,28 @@ +const fetch = require("node-fetch"); +const fs = require("fs/promises"); +const path = require("path"); + +const CACHE_PATH = path.join(__dirname, "..", "assets", "cache"); +const CHANGELOG_PATH = path.join(__dirname, "..", "assets", "changelog.txt"); +const BASE_URL = "https://discord.com"; + +const CHANGELOG_SCRIPT = "9c4b2d313c6e1c864e89.js"; + +(async () => { + const res = await fetch(`${BASE_URL}/assets/${CHANGELOG_SCRIPT}`); + const text = await res.text(); + + const newChangelogText = (await fs.readFile(CHANGELOG_PATH)) + .toString() + .replaceAll("\r", "") + .replaceAll("\n", "\\n") + .replaceAll("\'", "\\'"); + + const index = text.indexOf("e.exports='---changelog---") + 11; + const endIndex = text.indexOf("'\n", index); // hmm + + await fs.writeFile( + path.join(CACHE_PATH, CHANGELOG_SCRIPT), + text.substring(0, index) + newChangelogText + text.substring(endIndex) + ); +})(); \ No newline at end of file |