Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. chartCommand: function(message, bot) {
  2. values = message.content.split(' ');
  3. if (values.length > 1) {
  4. timeRange = 3;
  5. interval = 5;
  6. options = "";//blank unless specified later
  7. if (values.length === 3) {
  8. timeRange = parseInt(values[2]);
  9.  
  10. if (!isNaN(timeRange)) {
  11. if (timeRange > 14) {
  12. interval = "d";
  13. } else if (timeRange > 3) {
  14. interval = 30;
  15. }
  16.  
  17. if (timeRange > 200) {
  18. options = "&movAvg1=30&avgType2=SMA&movAvg2=200";
  19. } else if (timeRange > 30) {
  20. options = "&movAvg1=30";
  21. }
  22. }
  23. }
  24. ticker = values[1].toUpperCase();
  25. command = values[0].toLowerCase();
  26. if (command.startsWith('!chart2') || command.startsWith('!ch2')) {
  27. bot.channels.get(CONSTANTS.chartsAndDataChannel).send({
  28. embed: {
  29. color: 3447003,
  30. title: "Chart for " + ticker,
  31. url: "http://stockcharts.com/h-sc/ui?s=" + ticker,
  32. image: {
  33. url: "http://stockcharts.com/c-sc/sc?s=" + ticker + "&p=D&b=5&g=0&i=0&r=1500163462968&r=1500163483490"
  34. }
  35. }
  36. });
  37. helperFunctions.addSuccessReactionToMessage(message);
  38. message.channel.send("Chart posted to " + bot.channels.get(CONSTANTS.chartsAndDataChannel));
  39. } else if (command.startsWith('!chart') || command.startsWith('!ch')) {
  40. bot.channels.get(CONSTANTS.chartsAndDataChannel).send({
  41. embed: {
  42. color: 3447003,
  43. title: "Chart for " + ticker,
  44. url: "https://www.stockscores.com/chart.asp?TickerSymbol=" + ticker,
  45. image: {
  46. url: "https://www.stockscores.com/chart.asp?TickerSymbol=" + ticker + "&TimeRange=" + timeRange
  47. + "&Interval=" + interval + "&Volume=1&ChartType=CandleStick"
  48. + "&Stockscores=None&ChartWidth=1100&ChartHeight=480&LogScale=None&Band=None&avgType1=SMA"
  49. + "&Indicator1=MACD&Indicator2=RSI&Indicator3=None&Indicator4=None"
  50. + "&endDate=&CompareWith=&entryPrice=&stopLossPrice=&candles=redgreen" + options
  51. }
  52. }
  53. });
  54. helperFunctions.addSuccessReactionToMessage(message);
  55. message.channel.send("Chart posted to " + bot.channels.get(CONSTANTS.chartsAndDataChannel));
  56. }
  57. } else {
  58. message.author.send(CONSTANTS.chartErrorMessage);
  59. helperFunctions.addErrorReactionToMessage(message);
  60. }
  61. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement