staging stock addon
This commit is contained in:
@@ -16,7 +16,8 @@ module.exports = {
|
|||||||
**!random** - Selects a random article: *!random*
|
**!random** - Selects a random article: *!random*
|
||||||
**!random category** - Selects a random article by category: *!random sports*
|
**!random category** - Selects a random article by category: *!random sports*
|
||||||
**!answer** - Instant Live Search: *!answer salesforce*
|
**!answer** - Instant Live Search: *!answer salesforce*
|
||||||
**!slang** - Urban Dictionary Search: *!answer slang*
|
**!slang** - Urban Dictionary Search: *!slang slang*
|
||||||
|
**!stock** - AlphaVantage Stock Search: *!stock IBM*
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
32
commands/stock.js
Normal file
32
commands/stock.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
var libFlayer = require("../libFlayer.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'slang',
|
||||||
|
description: 'Slang',
|
||||||
|
async execute(message, args) {
|
||||||
|
try {
|
||||||
|
if (args.length < 1) {
|
||||||
|
message.reply(`Please use in !slang [question] format`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var question = encodeURIComponent(args.join(" "));
|
||||||
|
|
||||||
|
var stockData = await libFlayer.getStock(question);
|
||||||
|
message.reply(`**Search Stock Info**:
|
||||||
|
symbol: ${stockData.symbol}
|
||||||
|
open: ${stockData.open}
|
||||||
|
high: ${stockData.high}
|
||||||
|
low: ${stockData.low}
|
||||||
|
price: ${stockData.price}
|
||||||
|
volume: ${stockData.volume}
|
||||||
|
latest: ${stockData.latest}
|
||||||
|
previous: ${stockData.previous}
|
||||||
|
change: ${stockData.change}
|
||||||
|
percent: ${stockData.percent}
|
||||||
|
`);
|
||||||
|
} catch (e) {
|
||||||
|
message.reply(e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
43
libFlayer.js
43
libFlayer.js
@@ -266,6 +266,49 @@ exports.getSlang = async function (question) {
|
|||||||
return slangData;
|
return slangData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.getStock = async function (stock) {
|
||||||
|
|
||||||
|
var answerURL = `https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${stock}&interval=5min&apikey=demo`;
|
||||||
|
console.log(answerURL);
|
||||||
|
stockData = {
|
||||||
|
symbol: `Not Found`,
|
||||||
|
open: ``,
|
||||||
|
high: ``,
|
||||||
|
low: ``,
|
||||||
|
price: ``,
|
||||||
|
volume: ``,
|
||||||
|
latest: ``,
|
||||||
|
previous: ``,
|
||||||
|
change: ``,
|
||||||
|
percent: ``
|
||||||
|
}
|
||||||
|
await axios.get(answerURL)
|
||||||
|
.then(response => {
|
||||||
|
//console.log(response.data.list[0]);
|
||||||
|
|
||||||
|
stockData = {
|
||||||
|
symbol: `${unescape(response.data["Global Quote"]['01. symbol'])}`,
|
||||||
|
open: `${unescape(response.data["Global Quote"]['02. open'])}`,
|
||||||
|
high: `${unescape(response.data["Global Quote"]['03. high'])}`,
|
||||||
|
low: `${unescape(response.data["Global Quote"]['04. low'])}`,
|
||||||
|
price: `${unescape(response.data["Global Quote"]['05. price'])}`,
|
||||||
|
volume: `${unescape(response.data["Global Quote"]['06. volume'])}`,
|
||||||
|
latest: `${unescape(response.data["Global Quote"]['07. latest trading day'])}`,
|
||||||
|
previous: `${unescape(response.data["Global Quote"]['08. previous close'])}`,
|
||||||
|
change: `${unescape(response.data["Global Quote"]['09. change'])}`,
|
||||||
|
percent: `${unescape(response.data["Global Quote"]['10. change percent'])}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return stockData;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
return stockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSources - Returns libFlayer feed sources
|
* getSources - Returns libFlayer feed sources
|
||||||
* @constructor
|
* @constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user