mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
Merge pull request #266 from ykris45/patch-14
change api from coinmarketcap to coingecko
This commit is contained in:
commit
7d0e3bf750
1 changed files with 102 additions and 97 deletions
|
@ -8,20 +8,19 @@ exports.stats = {
|
||||||
usage: '',
|
usage: '',
|
||||||
description: 'Displays list of current Market stats',
|
description: 'Displays list of current Market stats',
|
||||||
process: function(bot, msg) {
|
process: function(bot, msg) {
|
||||||
needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=BTC', function(error, response) {
|
needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d', function(error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('coinmarketcap API is not available');
|
msg.channel.send('coingecko API is not available');
|
||||||
} else {
|
} else {
|
||||||
let data = response.body.data;
|
let data = response.body.data;
|
||||||
let rank = data.rank;
|
let rank = data.market_cap_rank;
|
||||||
let price_usd = Number(data.quotes.USD.price);
|
let price_btc = Number(data.current_price);
|
||||||
let price_btc = Number(data.quotes.BTC.price);
|
let market_cap_btc = Number(data.quotes.market_cap);
|
||||||
let market_cap_usd = Number(data.quotes.USD.market_cap);
|
|
||||||
let circulating_supply = Number(data.circulating_supply);
|
let circulating_supply = Number(data.circulating_supply);
|
||||||
let total_supply = Number(data.total_supply);
|
let total_supply = Number(data.total_supply);
|
||||||
let percent_change_1h = Number(data.quotes.USD.percent_change_1h);
|
let percent_change_1h = Number(data.price_change_percentage_1h_in_currency);
|
||||||
let percent_change_24h = Number(data.quotes.USD.percent_change_24h);
|
let percent_change_24h = Number(data.price_change_percentage_24h_in_currency);
|
||||||
let volume24_usd = Number(data.quotes.USD.volume_24h);
|
let volume24_btc = Number(data.total_volume);
|
||||||
let dt = new Date();
|
let dt = new Date();
|
||||||
let timestamp = dt.toUTCString();
|
let timestamp = dt.toUTCString();
|
||||||
let hr_indicator = ':thumbsup:';
|
let hr_indicator = ':thumbsup:';
|
||||||
|
@ -33,37 +32,41 @@ exports.stats = {
|
||||||
day_indicator = ':thumbsdown:';
|
day_indicator = ':thumbsdown:';
|
||||||
}
|
}
|
||||||
|
|
||||||
needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=GBP', function(error, response) {
|
needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=gbp&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('coinmarketcap API is not available');
|
msg.channel.send('coingecko API is not available');
|
||||||
} else {
|
} else {
|
||||||
data = response.body.data;
|
data = response.body.data;
|
||||||
let price_gbp = Number(data.quotes.GBP.price);
|
let price_gbp = Number(data.current_price);
|
||||||
needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=EUR', function(error, response) {
|
needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('coinmarketcap API is not available');
|
msg.channel.send('coingecko API is not available');
|
||||||
} else {
|
} else {
|
||||||
data = response.body.data;
|
data = response.body.data;
|
||||||
let price_eur = Number(data.quotes.EUR.price);
|
let price_eur = Number(data.current_price);
|
||||||
|
needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) {
|
||||||
|
if (error || response.statusCode !== 200) {
|
||||||
|
msg.channel.send('coingecko API is not available');
|
||||||
|
} else {
|
||||||
|
data = response.body.data;
|
||||||
|
let price_usd = Number(data.current_price);
|
||||||
let description = `**Rank: [${rank}](${statsurl})**
|
let description = `**Rank: [${rank}](${statsurl})**
|
||||||
**Data**
|
**Data**
|
||||||
Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl})
|
Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl})
|
||||||
Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl})
|
Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl})
|
||||||
Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl})
|
Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl})
|
||||||
24 Hour Volume: [$${volume24_usd}](${statsurl})
|
24 Hour Volume: [$${volume24_usd}](${statsurl})
|
||||||
|
|
||||||
**Price**
|
**Price**
|
||||||
BTC: [₿${price_btc.toFixed(8)}](${statsurl})
|
BTC: [₿${price_btc.toFixed(8)}](${statsurl})
|
||||||
USD: [$${price_usd.toFixed(2)}](${statsurl})
|
USD: [$${price_usd.toFixed(2)}](${statsurl})
|
||||||
EUR: [€${price_eur.toFixed(2)}](${statsurl})
|
EUR: [€${price_eur.toFixed(2)}](${statsurl})
|
||||||
GBP: [£${price_gbp.toFixed(2)}](${statsurl})
|
GBP: [£${price_gbp.toFixed(2)}](${statsurl})
|
||||||
|
|
||||||
**% Change**
|
**% Change**
|
||||||
1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator}
|
1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator}
|
||||||
|
|
||||||
1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator}
|
1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator}`;
|
||||||
|
|
||||||
`;
|
|
||||||
const embed = {
|
const embed = {
|
||||||
description: description,
|
description: description,
|
||||||
color: 7976557,
|
color: 7976557,
|
||||||
|
@ -76,7 +79,7 @@ GBP: [£${price_gbp.toFixed(2)}](${statsurl})
|
||||||
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
|
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
msg.channel.send({ embed });
|
msg.channel.send({embed});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -104,4 +107,6 @@ GBP: [£${price_gbp.toFixed(2)}](${statsurl})
|
||||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue