const fs = require('fs');
const sidebarTemplate = fs.readFileSync('sidebar.md', 'utf8');
var hb = new HockeyBar(
'anaheim-ducks'
, {
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
userId: process.env.REDDIT_USER,
userPassword: process.env.REDDIT_PASS,
subreddit: process.env.SUBREDDIT
}
, sidebarTemplate);
var currentDate = new Date();
hb.fetchTeamSchedule()
.then((data) => hb.asMarkdown(data))
.then((markdown) => hb.updateTemplate('***TEAM_SCHEDULE***', markdown))
.then(() => hb.fetchTeamSkaters())
.then((data) => hb.asMarkdown(data))
.then((markdown) => hb.updateTemplate('***TEAM_STATS***', markdown))
.then(() => hb.fetchTeamGoalies())
.then((data) => hb.asMarkdown(data))
.then((markdown) => hb.updateTemplate('***GOALIE_STATS***', markdown))
.then(() => hb.fetchDivisionStats())
.then((data) => hb.asMarkdown(data))
.then((markdown) => hb.updateTemplate('***DIV_STATS***', markdown))
.then(() => hb.fetchConferenceStats())
.then((data) => hb.asMarkdown(data))
.then((markdown) => hb.updateTemplate('***CONF_STATS***', markdown))
.then(() => hb.updateTemplate('***LAST_UPDATED***', `Last Updated: ${currentDate.toDateString()} at ${currentDate.toTimeString()}`))
.then(() => hb.updateRedditSidebar())
.then(() => console.log(hb.sidebarTemplate));