Merge pull request #81 from MSFTserver/patch-4

fix hash bot when WTM api is down[done]
This commit is contained in:
filipnyquist 2017-11-10 22:06:43 +01:00 committed by GitHub
commit 8baaae7cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,8 +20,7 @@ exports.timedhash = function(bot) {
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('Explorer API is not available');
}
else {
} else {
var data = response.body;
var height = Number(data.status.height);
var hashrate = data.status.hashrate;
@ -29,7 +28,7 @@ needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('whattomine API is not available');
} else {
}
var data = response.body;
var reward = Number(data.block_reward);
var block_time = Number(data.block_time);
@ -52,7 +51,6 @@ needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
};
bot.channels.get(ChannelID).send({ embed })
return
}
});
}
});
@ -80,7 +78,6 @@ exports.hash = {
return
}
function sendMiningInfo(bot, msg, suffix) {
if(!inPrivate(msg) && !hasHashBotChannels(msg)){
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to hash bot.');
@ -89,8 +86,7 @@ function sendMiningInfo(bot, msg, suffix) {
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('Explorer API is not available');
}
else {
} else {
var data = response.body;
var height = Number(data.status.height);
var hashrate = data.status.hashrate;
@ -98,7 +94,7 @@ function sendMiningInfo(bot, msg, suffix) {
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('whattomine API is not available');
} else {
}
var data = response.body;
var reward = Number(data.block_reward);
var block_time = Number(data.block_time);
@ -121,7 +117,6 @@ function sendMiningInfo(bot, msg, suffix) {
};
msg.channel.send({ embed });
return
}
});
}
});
@ -165,8 +160,5 @@ function sendProfitInfo(bot, msg, suffix) {
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
}