From 389290049db7348a3f99fd2eba43fddc7e9ce8d7 Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Thu, 31 May 2018 23:29:20 +0700 Subject: [PATCH 1/5] Fixed some variables --- bot/modules/hash.js | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/bot/modules/hash.js b/bot/modules/hash.js index 4d81e14..77e8da5 100644 --- a/bot/modules/hash.js +++ b/bot/modules/hash.js @@ -19,18 +19,18 @@ exports.timedhash = function(bot) { if (error || response.statusCode !== 200) { msg.channel.send('Explorer API is not available'); } else { - var data = response.body; - var height = Number(data.status.height); - var hashrate = data.status.hashrate; - var difficulty = Number(data.status.difficulty); + let data = response.body; + let height = Number(data.status.height); + let hashrate = data.status.hashrate; + let difficulty = Number(data.status.difficulty); needle.get('https://whattomine.com/coins/164.json', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('whattomine API is not available'); } - var data = response.body; - var reward = Number(data.block_reward); - var block_time = Number(data.block_time); - var difficulty24 = Number(data.difficulty24); + let data = response.body; + let reward = Number(data.block_reward); + let block_time = Number(data.block_time); + let difficulty24 = Number(data.difficulty24); description = 'Hashrate: ' + numberWithCommas(hashrate) + @@ -75,7 +75,7 @@ exports.hash = { usage: '', description: 'Displays current Hashrate of Network\n**!hash power **\n Displays potential Earnings For Given Hashrate', process: function(bot, msg, suffix) { - var command = '!hash'; + let command = '!hash'; words = suffix .trim() .split(' ') @@ -101,18 +101,18 @@ exports.hash = { if (error || response.statusCode !== 200) { msg.channel.send('Explorer API is not available'); } else { - var data = response.body; - var height = Number(data.status.height); - var hashrate = data.status.hashrate; - var difficulty = Number(data.status.difficulty); + let data = response.body; + let height = Number(data.status.height); + let hashrate = data.status.hashrate; + let difficulty = Number(data.status.difficulty); needle.get('https://whattomine.com/coins/164.json', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('whattomine API is not available'); } - var data = response.body; - var reward = Number(data.block_reward); - var block_time = Number(data.block_time); - var difficulty24 = Number(data.difficulty24); + let data = response.body; + let reward = Number(data.block_reward); + let block_time = Number(data.block_time); + let difficulty24 = Number(data.difficulty24); description = 'Hashrate: ' + numberWithCommas(hashrate) + @@ -159,18 +159,18 @@ exports.hash = { .filter(function(n) { return n !== ''; }); - var myhashrate = words[1]; + let myhashrate = words[1]; if (myhashrate == '' || myhashrate == null || myhashrate == undefined || myhashrate == ' ') { myhashrate = '100'; } - var Diff = response.body.difficulty24; - var Reward = response.body.block_reward; - var myHash = Number(myhashrate); - var LBC = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 3600; - var LBC24 = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 86400; - var LBC1w = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 604800; - var LBC1m = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 2628000; - var message = + let Diff = response.body.difficulty24; + let Reward = response.body.block_reward; + let myHash = Number(myhashrate); + let LBC = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 3600; + let LBC24 = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 86400; + let LBC1w = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 604800; + let LBC1m = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 2628000; + let message = 'With **' + myHash + ' Mh/s** and Average 24 hour Difficulty: **' + From 54638a2e7abe07bc61890173538c65b5e883e90c Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 1 Jun 2018 14:40:19 -0400 Subject: [PATCH 2/5] Explicitly Declared Implicitly declared vars --- bot/modules/lbrylink.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/modules/lbrylink.js b/bot/modules/lbrylink.js index 998c330..578eb2a 100644 --- a/bot/modules/lbrylink.js +++ b/bot/modules/lbrylink.js @@ -11,7 +11,7 @@ exports.lbrylink = function(bot, msg, suffix) { } if (msg.content.includes('lbry://')) { //Extract URL from Message - newURL = msg.content + let newURL = msg.content .replace('lbry://', 'https://open.lbry.io/') .match(/\bhttps?:\/\/\S+/gi) .toString(); @@ -28,8 +28,8 @@ exports.lbrylink = function(bot, msg, suffix) { //Check if Username Was Supplied if (newURL.includes('>')) { //Get rid of ID from message - parseID = newURL.split('>').pop(); - newURL = 'https://open.lbry.io' + parseID; + let parseID = newURL.split('>').pop(); + let newURL = 'https://open.lbry.io' + parseID; if (responseDebug) { console.log('Username Provided!'); console.log('parseID = ' + parseID); @@ -45,8 +45,8 @@ exports.lbrylink = function(bot, msg, suffix) { //Also check obscurity in username like ``@MSFTserver` vs `@MSFTserverPics` if (parseID.includes('/')) { //parse out extra params before `/` like `<@123456789>Pics` - parseID = parseID.split('/').pop(); - newURL = 'https://open.lbry.io/' + parseID; + let parseID = parseID.split('/').pop(); + let newURL = 'https://open.lbry.io/' + parseID; if (responseDebug) { console.log('Username no / check'); console.log('parseID = ' + parseID); From 620c7d91b8207cbc9bed233177838b48c50a7284 Mon Sep 17 00:00:00 2001 From: filipnyquist Date: Sat, 2 Jun 2018 20:37:35 +0200 Subject: [PATCH 3/5] Fixed bug with !stats an undeclered variable caused the command to fail --- bot/modules/stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index f8f534d..9a40bb4 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -56,7 +56,7 @@ exports.stats = { } else { let data = response.body[0]; let price_eur = Number(data.price_eur); - description = + let description = '**Rank: [' + rank + '](' + From 80ca7c2faf8138587131b20fd94b548db3ac9420 Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Tue, 5 Jun 2018 02:09:36 +0700 Subject: [PATCH 4/5] fix bugs on !hash --- bot/modules/hash.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/modules/hash.js b/bot/modules/hash.js index 77e8da5..a545870 100644 --- a/bot/modules/hash.js +++ b/bot/modules/hash.js @@ -31,7 +31,7 @@ exports.timedhash = function(bot) { let reward = Number(data.block_reward); let block_time = Number(data.block_time); let difficulty24 = Number(data.difficulty24); - description = + let description = 'Hashrate: ' + numberWithCommas(hashrate) + '\n' + @@ -76,14 +76,14 @@ exports.hash = { description: 'Displays current Hashrate of Network\n**!hash power **\n Displays potential Earnings For Given Hashrate', process: function(bot, msg, suffix) { let command = '!hash'; - words = suffix + let words = suffix .trim() .split(' ') .filter(function(n) { return n !== ''; }); - profitcommand = words[0]; - myhashrate = words[1]; + let profitcommand = words[0]; + let myhashrate = words[1]; if (profitcommand == 'power') { sendProfitInfo(bot, msg, suffix); return; @@ -113,7 +113,7 @@ exports.hash = { let reward = Number(data.block_reward); let block_time = Number(data.block_time); let difficulty24 = Number(data.difficulty24); - description = + let description = 'Hashrate: ' + numberWithCommas(hashrate) + '\n' + From ab0c928e6554a18eb53e168fa6fda20feae57f72 Mon Sep 17 00:00:00 2001 From: filipnyquist Date: Tue, 5 Jun 2018 22:16:58 +0200 Subject: [PATCH 5/5] Fixed variables for releasenotes --- bot/modules/releasenotes.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 8240557..9b11add 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -12,23 +12,24 @@ exports.releasenotes = { usage: '', description: 'gets current release notes from GITHUB', process: function(bot, msg, suffix) { - var headers = { + const headers = { 'Content-Type': 'application/json', 'User-Agent': 'Super Agent/0.0.1' }; // Configure the request - var options = { + const options = { url: 'https://api.github.com/repos/lbryio/lbry-app/releases/latest', method: 'GET', headers: headers }; // Start the request + let message; request(options, function(error, response, body) { - releasemessage = JSON.parse(body).body; - releasename = JSON.parse(body).name; - releasedate = JSON.parse(body).published_at; - releaseurl = JSON.parse(body).html_url; + let releasemessage = JSON.parse(body).body; + let releasename = JSON.parse(body).name; + let releasedate = JSON.parse(body).published_at; + let releaseurl = JSON.parse(body).html_url; if (releasemessage.length < 2000) { message = { embed: { @@ -64,12 +65,12 @@ exports.releasenotes = { .filter(function(n) { return n !== ''; }); - releasemessage1 = message[0]; - releasemessage2 = message[1]; - releasemessage3 = message[2]; - releasemessage4 = message[3]; - releasemessage5 = message[4]; - message1 = { + let releasemessage1 = message[0]; + let releasemessage2 = message[1]; + let releasemessage3 = message[2]; + let releasemessage4 = message[3]; + let releasemessage5 = message[4]; + let message1 = { embed: { title: '*Download ' + releasename + ' here!*', description: releasemessage1, @@ -86,7 +87,7 @@ exports.releasenotes = { } } }; - message2 = { + let message2 = { embed: { description: releasemessage2, color: 7976557, @@ -100,7 +101,7 @@ exports.releasenotes = { } } }; - message3 = { + let message3 = { embed: { description: releasemessage3, color: 7976557, @@ -114,7 +115,7 @@ exports.releasenotes = { } } }; - message4 = { + let message4 = { embed: { description: releasemessage4, color: 7976557, @@ -128,7 +129,7 @@ exports.releasenotes = { } } }; - message5 = { + let message5 = { embed: { description: releasemessage5, color: 7976557,