buddy

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit c71dd1948bebfbfe3bef5516b20483582741a250
parent 8d1f1caf98aeaf392d5bcc7b03a804ded3dd0545
Author: underd0g1 <hide4@comcast.net>
Date:   Sat, 12 Sep 2020 00:51:20 -0400

started stock api integration

Diffstat:
Mevents/ready.js | 2+-
Mlib/3party.js | 15+++++++++++++--
Mlib/processing.js | 3+++
3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/events/ready.js b/events/ready.js @@ -4,7 +4,7 @@ const config = require("../config/config.js"); const startup = (client) => { client.on('ready', ()=>{ - console.log(client.user) + console.log('connected as ' + client.user.tag) client.user.setActivity('Node.js vids', { type: 'Watching' }); client.guilds.cache.forEach((guild)=>{ diff --git a/lib/3party.js b/lib/3party.js @@ -7,7 +7,8 @@ const urls = { beer: 'https://sandbox-api.brewerydb.com/v2/beer/random/?', foas1: 'https://www.foaas.com/operations', foas2:'https://www.foaas.com', - code: 'https://api.github.com/repos/underd0g1/buddy' + code: 'https://api.github.com/repos/underd0g1/buddy', + stocks: 'https://query1.finance.yahoo.com/v7/finance/quote?symbols=AAPL' } @@ -94,10 +95,20 @@ const code = async(recievedMessage) => { "Language: " + data.language; } + +const stocks = async(receivedMessage)=>{ + var req = await fetch(urls.stocks); + var data = await req.json(); + console.log(data.quoteResponse.result); + return data.quoteResponse.result[0].symbol + data.quoteResponse.result[0].regularMarketPrice + +} + module.exports = { iss, joke, beer, foas1, - code + code, + stocks } diff --git a/lib/processing.js b/lib/processing.js @@ -32,6 +32,9 @@ const tool = require("./tools.js"); case "foas": message.channel.send(await apiroute.foas1()); break; + case "stocks": + message.channel.send(await apiroute.stocks()); + break; default: tool.help(arguements, message); break;