Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chartCommand: function(message, bot) {
- values = message.content.split(' ');
- if (values.length > 1) {
- timeRange = 3;
- interval = 5;
- options = "";//blank unless specified later
- if (values.length === 3) {
- timeRange = parseInt(values[2]);
- if (!isNaN(timeRange)) {
- if (timeRange > 14) {
- interval = "d";
- } else if (timeRange > 3) {
- interval = 30;
- }
- if (timeRange > 200) {
- options = "&movAvg1=30&avgType2=SMA&movAvg2=200";
- } else if (timeRange > 30) {
- options = "&movAvg1=30";
- }
- }
- }
- ticker = values[1].toUpperCase();
- command = values[0].toLowerCase();
- if (command.startsWith('!chart2') || command.startsWith('!ch2')) {
- bot.channels.get(CONSTANTS.chartsAndDataChannel).send({
- embed: {
- color: 3447003,
- title: "Chart for " + ticker,
- url: "http://stockcharts.com/h-sc/ui?s=" + ticker,
- image: {
- url: "http://stockcharts.com/c-sc/sc?s=" + ticker + "&p=D&b=5&g=0&i=0&r=1500163462968&r=1500163483490"
- }
- }
- });
- helperFunctions.addSuccessReactionToMessage(message);
- message.channel.send("Chart posted to " + bot.channels.get(CONSTANTS.chartsAndDataChannel));
- } else if (command.startsWith('!chart') || command.startsWith('!ch')) {
- bot.channels.get(CONSTANTS.chartsAndDataChannel).send({
- embed: {
- color: 3447003,
- title: "Chart for " + ticker,
- url: "https://www.stockscores.com/chart.asp?TickerSymbol=" + ticker,
- image: {
- url: "https://www.stockscores.com/chart.asp?TickerSymbol=" + ticker + "&TimeRange=" + timeRange
- + "&Interval=" + interval + "&Volume=1&ChartType=CandleStick"
- + "&Stockscores=None&ChartWidth=1100&ChartHeight=480&LogScale=None&Band=None&avgType1=SMA"
- + "&Indicator1=MACD&Indicator2=RSI&Indicator3=None&Indicator4=None"
- + "&endDate=&CompareWith=&entryPrice=&stopLossPrice=&candles=redgreen" + options
- }
- }
- });
- helperFunctions.addSuccessReactionToMessage(message);
- message.channel.send("Chart posted to " + bot.channels.get(CONSTANTS.chartsAndDataChannel));
- }
- } else {
- message.author.send(CONSTANTS.chartErrorMessage);
- helperFunctions.addErrorReactionToMessage(message);
- }
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement