From a5758d1702b1d5d92c8c8c38342019dc4aefbe8b Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Tue, 12 Sep 2023 13:18:24 -0600 Subject: [PATCH] Hm --- .gitignore | 3 ++- index.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 7096826..5acf970 100755 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,5 @@ dist config.json -package-lock.json \ No newline at end of file +package-lock.json +tf_*.txt \ No newline at end of file diff --git a/index.js b/index.js index d8c9f8d..baacf78 100755 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const config = require("./config.json"); const colors = require("colors"); const axios = require("axios"); +const fs = require("fs"); const SteamUser = require("steam-user"); const TeamFortress2 = require("tf2"); const Discord = require("discord.js"); @@ -15,11 +16,21 @@ let tf2 = new TeamFortress2(user); axios.get("https://wiki.teamfortress.com/w/images/c/cf/Tf_english.txt").then((res) => { // set lang from body tf2.setLang(res.data) + // Save a local copy + fs.writeFileSync("./tf_english.txt", res.data); + console.log(`${colors.yellow("[TF2]")} Saved backup TF2 Lang File`); if (tf2.lang) return console.log(`${colors.yellow("[TF2]")} Loaded TF2 Lang File`); console.log(`${colors.red("[TF2]")} Failed to load TF2 Lang File`); }).catch((err) => { - console.log(`${colors.red("[TF2]")} Failed to load TF2 Lang File`); - console.log(err); + console.log(`${colors.red("[TF2]")} Failed to load TF2 Lang File from wiki, trying local file`); + // try to load local file + try { + tf2.setLang(fs.readFileSync("./tf_english.txt", "utf8")); + if (tf2.lang) return console.log(`${colors.yellow("[TF2]")} Loaded TF2 Lang File`); + console.log(`${colors.red("[TF2]")} Failed to load TF2 Lang File`); + } catch (err) { + console.log(`${colors.red("[TF2]")} Failed to load TF2 Lang File`); + } }) user.logOn(config.steam);