aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2022-03-11 18:23:24 -0700
committerBryson Steck <steck.bryson@gmail.com>2022-03-11 18:23:24 -0700
commit0a95dea1b6d2cae582ed8ef65eb6efcb656816ac (patch)
tree8b27220203c065eab04a2d2edf44e2e49abc994a
parentab29cd51d17c3044dde1bb1c954275f2761c4a13 (diff)
downloadlset-0a95dea1b6d2cae582ed8ef65eb6efcb656816ac.tar
lset-0a95dea1b6d2cae582ed8ef65eb6efcb656816ac.tar.gz
lset-0a95dea1b6d2cae582ed8ef65eb6efcb656816ac.tar.bz2
trying to fix undefined again
-rw-r--r--twitch-bot/bot.js48
1 files changed, 8 insertions, 40 deletions
diff --git a/twitch-bot/bot.js b/twitch-bot/bot.js
index d0220f7..f119771 100644
--- a/twitch-bot/bot.js
+++ b/twitch-bot/bot.js
@@ -1,48 +1,16 @@
const tmi = require('tmi.js');
const fs = require('fs');
-var settings, reacts, commands, mod_commands;
// read settings and reactions json files
-fs.readFileSync('./settings.json', 'utf8', (err, data) => {
- if (err) {
- console.log(`Error reading settings file from disk: ${err}`);
- process.exit(1);
- } else {
- // parse JSON string to JSON object
- settings = JSON.parse(data);
- }
-});
-
-fs.readFileSync('./reacts.json', 'utf8', (err, data) => {
- if (err) {
- console.log(`Error reading reacts file from disk: ${err}`);
- process.exit(1);
- } else {
- // parse JSON string to JSON object
- reacts = JSON.parse(data);
- }
-});
-
-fs.readFileSync('./commands.json', 'utf8', (err, data) => {
- if (err) {
- console.log(`Error reading commands file from disk: ${err}`);
- process.exit(1);
- } else {
- // parse JSON string to JSON object
- commands = JSON.parse(data);
- }
-});
-
-fs.readFileSync('./mod_commands.json', 'utf8', (err, data) => {
- if (err) {
- console.log(`Error reading mod commands file from disk: ${err}`);
- process.exit(1);
- } else {
- // parse JSON string to JSON object
- mod_commands = JSON.parse(data);
- }
-});
+try {
+ const settings = fs.readFileSync('./settings.json', 'utf8');
+ const reacts = fs.readFileSync('./reacts.json', 'utf8');
+ const commands = fs.readFileSync('./commands.json', 'utf8');
+ const mod_commands = fs.readFileSync('./mod_commands.json', 'utf8');
+} catch (err) {
+ console.error("An error occured trying to read the files for the Twitch bot: " + err);
+}
const opts = {
identity: {