Skip to content

Commit 8321e35

Browse files
committed
added startup message and bot enable config check
1 parent f46ac44 commit 8321e35

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

adafruit.js

+12
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,24 @@ let eightGigActive = false;
5858
// flag indicating if the bot is currently suspended from making queries to Adafruit.com (sleep mode to not query outside of their hours)
5959
let sleepModeActive = false;
6060

61+
// check that at least one bot is enabled and yell at the user if not
62+
if (!config.enableDiscordBot && !config.enableSlackBot) {
63+
console.log(chalk.red('\n[ERROR]') + ' At least one bot must be enabled in config.json. Please enable the bot(s) you want to use and ensure they are configured properly. Exiting...');
64+
console.log(chalk.yellow('See the README.md for more information if you need help.\n'));
65+
process.exit(1);
66+
}
67+
6168
// connect to discord (if discord bot is enabled)
6269
if (config.enableDiscordBot) client.login(config.discordBotToken);
6370

6471
// schedule the stock status update to be called at the specified interval
6572
setInterval(() => { checkStockStatus(); }, config.updateIntervalSeconds * 1000);
6673

74+
// show a startup message so the user knows the bot is running (if only using the Slack bot)
75+
if (!config.enableDiscordBot) {
76+
console.log(chalk.green(chalk.yellow('\n[BOT START]') + ' I\'m watching for stock updates now! I\'ll check Adafruit every ' + chalk.cyan(config.updateIntervalSeconds) + ' seconds...\n'));
77+
}
78+
6779

6880

6981
// -------------------------------------------

0 commit comments

Comments
 (0)