returnmessage.reply("The command format is: _!stocks <stock_name, 'hours'> <trade, quote, bars> [after]_");
}
message.reply({embeds:[embd]});
})
}catch(err){
console.error(err);
message.reply("Uh Oh, there's been an error!");
}
}
functiongetData(bot,message,args){
varstock;
if(args.length<1){
returnmessage.reply("Please specify a stock (ex: AAPL, GOOG, etc)")
}else{stock=args[0];}
constformat=`yyyy-MM-dd HH:mm:ss`;
constdate=dateFns.format(newDate(),format);
alpaca.getClock().then((clock)=>{
// var txt = `The market is currently ${clock.is_open ? 'open.' : 'closed.'}`;
alpaca.getCalendar({
start:date,
end:date
}).then((calendars)=>{
lettemp;
if(clock.is_open||args[2]=='after'){
if(args[0]=='hours'){
temp=`The markets opened at ${calendars[0].open} and will close at ${calendars[0].close} on ${date}.`;
returnmessage.reply(temp);
}
getStockData(bot,message,args,stock);
}else{
// `The market is currently ${clock.is_open ? 'open.' : 'closed.'}`
//May be innacurate?
temp=`_The markets closed at \`${calendars[0].close}\` and will open again at \`${calendars[0].open}\` on \`${dateFns.format((newDate()).setDate(newDate().getDate()+1),'yyyy-MM-dd')}\`.\nTo get the last snapshot before market closure, add the \`after\` keyword to the end of your command (trade and bars ONLY), ex: !stocks GOOG bars after_`;