From 74d4dec0dcf8bc2739c33ab2457a350df46a161e Mon Sep 17 00:00:00 2001 From: ProfessorDey Date: Tue, 8 Oct 2019 22:54:01 +0100 Subject: [PATCH 1/7] Simplify rolesetter.js Control Logic Eliminates nesting of if-else statements and follows imperative control logic, making it much clearer what error messages are which and what order logic is handled in. Also neatens up the calls to 'msg.channel.send' into a single compact function declaration. Also eliminates case sensitivity entirely with a minimal performance hit by only performing '.toLowerCase()' on the first check for new/oldrole, though this could be replaced with a regexp object test instead. Every other comparison uses the matched role's name as this is guaranteed to be the correct case, assuming no issues with the config itself. This means users can enter the role in any case, preventing the biggest irritation to most users besides spelling errors. --- bot/modules/rolesetter.js | 128 ++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 66 deletions(-) diff --git a/bot/modules/rolesetter.js b/bot/modules/rolesetter.js index a7ba2b6..af7351e 100644 --- a/bot/modules/rolesetter.js +++ b/bot/modules/rolesetter.js @@ -13,47 +13,46 @@ exports.addrole = { usage: '', description: 'Adds you to specified role', process: function(bot, msg, suffix) { - //rolelist.allowedroles = rolelist.allowedroles.map(v => v.toLowerCase()); - // Here the bot,msg and suffix is avaible, this function can be async if needed. - let newrole = msg.guild.roles.find('name', suffix); + // Here the bot, msg and suffix is avaible, this function can be async if needed. + // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. + let newrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); + // Baserole is assumed to already be case accurate as it's handled in the config itself. let baserole = msg.guild.roles.find('name', rolelist.baserole); - // Checks if the user put a role in the message. - if (inPrivate(msg)) { - msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.'); + + // Provide shortened syntax for the sake of code cleanliness + let send = (msgTxt) => { msg.channel.send(msgTxt); return; }; + let rolecmd = botconfig.prefix + "roles"; + + // Checks if the user has messaged the bot via Direct Message + if (inPrivate(msg)) + return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + // Checks if the user included a role in their message + if (!suffix) + return send("Please specify a role. Type " + rolecmd + " to see which you may add yourself!"); + // Checks if there is a matching role found on the server + if(!newrole) + return send("The role specified `" + suffix + "` does not exist on this server!"); + // Checks that the allowed roles and base role against the matched role's name, since this eliminates case sensitivity issues + if(!rolelist.allowedroles.includes(newrole.name) && !rolelist.baserole.includes(newrole.name)) + return send("That role isn't one you can add yourself to! Type " + rolecmd + " command to find out which ones are allowed."); + // Use the matched name to check against the member's existing roles + if(msg.member.roles.find('name', newrole.name)) + return send("It seems you already have the " + newrole.name + "role"); + + // Assuming all these factors succeed, add the role + msg.member.addRole(newrole).then(send(msg.member + " has been added to the " + newrole.name + " role!")); + + // Check if a baserole is actually set + if(!rolelist.baserole) return; - } else { - if (suffix) { - //suffix = suffix.toLowerCase(); - // Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config. - if (rolelist.allowedroles.includes(suffix) || rolelist.baserole.includes(suffix)) { - // Checks if the role even exists in the discord server - if (newrole !== null) { - // Checks if the member has the role that they are trying to add - if (!msg.member.roles.find('name', suffix)) { - msg.member.addRole(newrole).then(msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!')); - if (rolelist.baserole !== ' ') { - if (baserole !== null) { - // Checks if Member has the baserole, and also checks if they just added the baserole - if (!msg.member.roles.find('name', rolelist.baserole) && suffix !== rolelist.baserole) { - msg.member.addRole(baserole).then(msg.channel.send(msg.member + ' has been added to the ' + rolelist.baserole + ' role!')); - } - } else { - msg.channel.send('The ' + rolelist.baserole + " Role doesn't exist. Please add that role first!"); - } - } - } else { - msg.channel.send('It seems that you already have that role! Try removing it first with the ' + botconfig.prefix + 'delrole command!'); - } - } else { - msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!'); - } - } else { - msg.channel.send("That role isn't one you can add yourself to! Please run the " + botconfig.prefix + 'roles command to find out which ones are allowed.'); - } - } else { - msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!'); - } - } + // Confirm that the role exists on the server and if not then be sure to send a nag message + if(!baserole) + return send("The base role of " + rolelist.baserole + " has been set in config but is missing from the server"); + // Confirm if the user has the baserole already, including if it was added just now + if(msg.member.roles.find('name', baserole.name)) + return; + // Add the base role and avoid spamming the user by only mentioning them in the previous message + msg.member.addRole(baserole).then(send("We also added the base " + rolelist.baserole + " role for you!")); } }; exports.delrole = { @@ -61,33 +60,30 @@ exports.delrole = { description: 'Deletes the specified role from your account', process: function(bot, msg, suffix) { // Here in the bot, msg and suffix are available, this function can be async if needed. - let oldrole = msg.guild.roles.find('name', suffix); - // Checks if the user put a role in the message. - if (inPrivate(msg)) { - msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.'); - return; - } else { - if (suffix) { - // Checks if the role mentioned in the message is in the allowed roles listed in the Wunderbot config. - if (rolelist.allowedroles.includes(suffix)) { - // Checks if the role exists in the Discord server - if (oldrole !== null) { - // Checks if the member has the role that they are trying to add - if (msg.member.roles.find('name', suffix)) { - msg.member.removeRole(oldrole).then(msg.channel.send(msg.member + ' has been removed from the ' + suffix + ' role!')); - } else { - msg.channel.send("You don't seem to have that role! Try adding it first with the " + botconfig.prefix + 'addrole command!'); - } - } else { - msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!'); - } - } else { - msg.channel.send("That role isn't one you can add yourself to! Please run the " + botconfig.prefix + 'roles command to find out which ones are allowed.'); - } - } else { - msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!'); - } - } + // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. + let oldrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); + // Provide shortened syntax for the sake of code cleanliness + let send = (msgTxt) => { msg.channel.send(msgTxt); return; }; + let rolecmd = botconfig.prefix + "roles"; + + // Checks if the user has messaged the bot via Direct Message + if (inPrivate(msg)) + return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + // Checks if the user included a role in their message + if (!suffix) + return send("Please specify a role. Type " + rolecmd + " to see which you may remove yourself!"); + // Checks if there is a matching role found on the server + if(!newrole) + return send("The role specified `" + suffix + "` does not exist on this server!"); + // Checks that the allowed roles against the matched role's name, since this eliminates case sensitivity issues + if(!rolelist.allowedroles.includes(oldrole.name)) + return send("That role isn't one you can remove yourself! If you need it removed, please ask a moderator!"); + // Use the matched name to check against the member's existing roles + if(!msg.member.roles.find('name', oldrole.name)) + return send("It seems you don't actually have the " + oldrole.name + "role! Mission accomplished!"); + + // Assuming all these factors succeed, add the role + msg.member.removeRole(oldrole).then(send(msg.member + " has been removed from the " + oldrole.name + " role!")); } }; exports.roles = { From 516d0737cab6404c3bd44e1929b627edf83f8149 Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Wed, 9 Oct 2019 22:42:32 +0700 Subject: [PATCH 2/7] change api from coinmarketcap to coingecko --- bot/modules/stats.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 8dd774e..e3af7ff 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -8,20 +8,20 @@ exports.stats = { usage: '', description: 'Displays list of current Market stats', 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) { msg.channel.send('coinmarketcap API is not available'); } else { let data = response.body.data; - let rank = data.rank; - let price_usd = Number(data.quotes.USD.price); - let price_btc = Number(data.quotes.BTC.price); + let rank = data.market_cap_rank; + let price_btc = Number(data.current_price); let market_cap_usd = Number(data.quotes.USD.market_cap); let circulating_supply = Number(data.circulating_supply); let total_supply = Number(data.total_supply); - let percent_change_1h = Number(data.quotes.USD.percent_change_1h); - let percent_change_24h = Number(data.quotes.USD.percent_change_24h); - let volume24_usd = Number(data.quotes.USD.volume_24h); + let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); + let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); + let volume24_btc = Number(data.total_volume); let dt = new Date(); let timestamp = dt.toUTCString(); let hr_indicator = ':thumbsup:'; @@ -33,18 +33,24 @@ exports.stats = { 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) { msg.channel.send('coinmarketcap API is not available'); } else { data = response.body.data; - let price_gbp = Number(data.quotes.GBP.price); - needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=EUR', function(error, response) { + let price_gbp = Number(data.current_price); + 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) { msg.channel.send('coinmarketcap API is not available'); } else { 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('coinmarketcap API is not available'); + } else { + data = response.body.data; + let price_usd = Number(data.current_price); let description = `**Rank: [${rank}](${statsurl})** **Data** Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) From 4802cebf63568671d536dc669cf20ab841774241 Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Wed, 9 Oct 2019 23:39:37 +0700 Subject: [PATCH 3/7] Update stats.js --- bot/modules/stats.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index e3af7ff..20d2c7d 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -11,12 +11,12 @@ exports.stats = { 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) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { let data = response.body.data; let rank = data.market_cap_rank; let price_btc = Number(data.current_price); - let market_cap_usd = Number(data.quotes.USD.market_cap); + let market_cap_btc = Number(data.quotes.market_cap); let circulating_supply = Number(data.circulating_supply); let total_supply = Number(data.total_supply); let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); @@ -35,19 +35,19 @@ exports.stats = { 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) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { data = response.body.data; let price_gbp = Number(data.current_price); 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) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { data = response.body.data; - let price_eur = Number(data.current_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('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { data = response.body.data; let price_usd = Number(data.current_price); From 5f825b9156594b49f1eefdf57e29138d898c2b2c Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Wed, 9 Oct 2019 23:41:33 +0700 Subject: [PATCH 4/7] update as niko request --- 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 20d2c7d..428878a 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -44,7 +44,7 @@ exports.stats = { msg.channel.send('coingecko API is not available'); } else { data = response.body.data; - let price_eur\ = Number(data.current_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'); From 28e95245b0c5ccc9752886718721eaeb9c35ae76 Mon Sep 17 00:00:00 2001 From: Ralph Date: Wed, 9 Oct 2019 20:28:26 -0400 Subject: [PATCH 5/7] Closed string to resolve travis build --- bot/modules/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 428878a..6cfe1ec 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -8,8 +8,8 @@ exports.stats = { usage: '', description: 'Displays list of current Market stats', process: function(bot, msg) { - 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) { + 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) { msg.channel.send('coingecko API is not available'); } else { From 61ee16ce6423f8f46bddfd09bf00024de510d8f7 Mon Sep 17 00:00:00 2001 From: Ralph Date: Wed, 9 Oct 2019 20:37:54 -0400 Subject: [PATCH 6/7] Resolved syntax issues. --- bot/modules/stats.js | 203 +++++++++++++++++++++---------------------- 1 file changed, 101 insertions(+), 102 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 6cfe1ec..e30e447 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -1,113 +1,112 @@ let needle = require('needle'); let statsurl = 'https://coinmarketcap.com/currencies/library-credit/'; exports.commands = [ - 'stats' // command that is in this file, every command needs it own export as shown below + 'stats' // command that is in this file, every command needs it own export as shown below ]; exports.stats = { - usage: '', - description: 'Displays list of current Market stats', - process: function(bot, msg) { - 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) { - msg.channel.send('coingecko API is not available'); - } else { - let data = response.body.data; - let rank = data.market_cap_rank; - let price_btc = Number(data.current_price); - let market_cap_btc = Number(data.quotes.market_cap); - let circulating_supply = Number(data.circulating_supply); - let total_supply = Number(data.total_supply); - let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); - let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); - let volume24_btc = Number(data.total_volume); - let dt = new Date(); - let timestamp = dt.toUTCString(); - let hr_indicator = ':thumbsup:'; - let day_indicator = ':thumbsup:'; - if (percent_change_1h < 0) { - hr_indicator = ':thumbsdown:'; - } - if (percent_change_24h < 0) { - day_indicator = ':thumbsdown:'; - } - - 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) { - msg.channel.send('coingecko API is not available'); - } else { - data = response.body.data; - let price_gbp = Number(data.current_price); - 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) { + usage: '', + description: 'Displays list of current Market stats', + process: function(bot, msg) { + 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) { msg.channel.send('coingecko API is not available'); - } else { - data = response.body.data; - 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})** -**Data** -Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) -Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl}) -Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl}) -24 Hour Volume: [$${volume24_usd}](${statsurl}) + } else { + let data = response.body.data; + let rank = data.market_cap_rank; + let price_btc = Number(data.current_price); + let market_cap_btc = Number(data.quotes.market_cap); + let circulating_supply = Number(data.circulating_supply); + let total_supply = Number(data.total_supply); + let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); + let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); + let volume24_btc = Number(data.total_volume); + let dt = new Date(); + let timestamp = dt.toUTCString(); + let hr_indicator = ':thumbsup:'; + let day_indicator = ':thumbsup:'; + if (percent_change_1h < 0) { + hr_indicator = ':thumbsdown:'; + } + if (percent_change_24h < 0) { + day_indicator = ':thumbsdown:'; + } -**Price** -BTC: [₿${price_btc.toFixed(8)}](${statsurl}) -USD: [$${price_usd.toFixed(2)}](${statsurl}) -EUR: [€${price_eur.toFixed(2)}](${statsurl}) -GBP: [£${price_gbp.toFixed(2)}](${statsurl}) + 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) { + msg.channel.send('coingecko API is not available'); + } else { + data = response.body.data; + let price_gbp = Number(data.current_price); + 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) { + msg.channel.send('coingecko API is not available'); + } else { + data = response.body.data; + 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})** + **Data** + Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) + Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl}) + Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl}) + 24 Hour Volume: [$${volume24_usd}](${statsurl}) + + **Price** + BTC: [₿${price_btc.toFixed(8)}](${statsurl}) + USD: [$${price_usd.toFixed(2)}](${statsurl}) + EUR: [€${price_eur.toFixed(2)}](${statsurl}) + GBP: [£${price_gbp.toFixed(2)}](${statsurl}) + + **% Change** + 1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator} + + 1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator}`; + const embed = { + description: description, + color: 7976557, + footer: { + text: 'Last Updated: ' + timestamp + }, + author: { + name: 'Coin Market Cap Stats (LBC)', + url: statsurl, + icon_url: 'https://spee.ch/2/pinkylbryheart.png' + } + }; + msg.channel.send({embed}); + } + }); + } + }); + } + }); -**% Change** -1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator} + function parse_obj(obj) { + let array = []; + let prop; + for (prop in obj) { + if (obj.hasOwnProperty(prop)) { + let key = parseInt(prop, 10); + let value = obj[prop]; + if (typeof value == 'object') { + value = parse_obj(value); + } + array[key] = value; + } + } + return array; + } -1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator} - -`; - const embed = { - description: description, - color: 7976557, - footer: { - text: 'Last Updated: ' + timestamp - }, - author: { - name: 'Coin Market Cap Stats (LBC)', - url: statsurl, - icon_url: 'https://spee.ch/2/pinkylbryheart.png' - } - }; - msg.channel.send({ embed }); - } - }); - } - }); - } - }); - - function parse_obj(obj) { - let array = []; - let prop; - for (prop in obj) { - if (obj.hasOwnProperty(prop)) { - let key = parseInt(prop, 10); - let value = obj[prop]; - if (typeof value == 'object') { - value = parse_obj(value); - } - array[key] = value; - } - } - return array; + function numberWithCommas(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); + } + } + }) } - - function numberWithCommas(x) { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); - } - } -}; +} From 72cee0943e7aad612eb024fbaa305dcc8db777eb Mon Sep 17 00:00:00 2001 From: Ralph Date: Wed, 9 Oct 2019 20:40:32 -0400 Subject: [PATCH 7/7] Correct syntax --- config/commands.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/commands.json b/config/commands.json index 7426fdb..86ab81e 100644 --- a/config/commands.json +++ b/config/commands.json @@ -912,7 +912,7 @@ "url": "https://lbry.com/faq", "icon_url": "https://spee.ch/2/pinkylbryheart.png" } - } + }, "!piratebay": { "usage": "",