From d31f839039895daf4f14752b3b5caf6bfc7ecd1a Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Wed, 20 Dec 2017 00:28:28 +0100 Subject: [PATCH] formatted code --- bot/helpers.js | 16 +++--- bot/modules/lbrylink.js | 20 ++++---- bot/modules/releasenotes.js | 27 ++++++---- bot/modules/rolesetter.js | 100 ++++++++++++++++++++---------------- bot/plugins.js | 20 +++----- 5 files changed, 100 insertions(+), 83 deletions(-) diff --git a/bot/helpers.js b/bot/helpers.js index 3bd4650..3be71b3 100644 --- a/bot/helpers.js +++ b/bot/helpers.js @@ -1,10 +1,10 @@ -let config = require("config"); -let permRanks = config.get("moderation"); -let speechBotChannels = config.get("speechbot"); -let priceBotChannels = config.get("pricebot"); -let ExcludedSpam = config.get("spamdetection"); -let hashBotChannels = config.get("hashbot"); -let statsBotChannels = config.get("statsbot"); +let config = require('config'); +let permRanks = config.get('moderation'); +let speechBotChannels = config.get('speechbot'); +let priceBotChannels = config.get('pricebot'); +let ExcludedSpam = config.get('spamdetection'); +let hashBotChannels = config.get('hashbot'); +let statsBotChannels = config.get('statsbot'); // Checks if user is allowed to use a command only for mods/team members exports.hasPerms = function(msg) { @@ -13,7 +13,7 @@ exports.hasPerms = function(msg) { // Check if command was sent in dm exports.inPrivate = function(msg) { - return msg.channel.type == "dm"; + return msg.channel.type == 'dm'; }; // Checks if Message was sent from a channel in speechBot Channels list diff --git a/bot/modules/lbrylink.js b/bot/modules/lbrylink.js index eee1070..c1696fd 100644 --- a/bot/modules/lbrylink.js +++ b/bot/modules/lbrylink.js @@ -13,25 +13,25 @@ exports.lbrylink = function(bot, msg, suffix) { if (link != -1) { var text = msg.content.replace("lbry://", "https://open.lbry.io/"); var message = GetWordByPos(text, link); - if (ResponseDebug == "true") { - console.log("text = " + text); - console.log("message = " + message); - } + if (ResponseDebug == "true") { + console.log("text = " + text); + console.log("message = " + message); + } if (message === "https://open.lbry.io/") { return; } if (message.search(">") != -1) { parsename = message.split(">").pop(); - if (parsename.search("/") == -1){ + if (parsename.search("/") == -1) { return; } newname = message.split("/").pop(); message = "https://open.lbry.io/" + newname; - if (ResponseDebug == "true") { - console.log("Username Provided!"); - console.log("parsename = " + parsename); - console.log("newname = " + newname); - } + if (ResponseDebug == "true") { + console.log("Username Provided!"); + console.log("parsename = " + parsename); + console.log("newname = " + newname); + } } else { var newname = message.replace("https://open.lbry.io/", ""); } diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 52d4514..c7e28e4 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -39,7 +39,8 @@ exports.releasenotes = { timestamp: releasedate, author: { name: "Lbry-app Release Notes for " + releasename, - icon_url: "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" + icon_url: + "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" }, footer: { icon_url: "https://i.imgur.com/yWf5USu.png", @@ -58,9 +59,12 @@ exports.releasenotes = { msg.author.send(message); } } else { - message = releasemessage.trim().split("###").filter(function(n) { - return n !== ""; - }); + message = releasemessage + .trim() + .split("###") + .filter(function(n) { + return n !== ""; + }); releasemessage1 = message[0]; releasemessage2 = message[1]; releasemessage3 = message[2]; @@ -75,7 +79,8 @@ exports.releasenotes = { timestamp: releasedate, author: { name: "Lbry-app Release Notes for " + releasename, - icon_url: "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" + icon_url: + "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" }, footer: { icon_url: "https://i.imgur.com/yWf5USu.png", @@ -89,7 +94,8 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, author: { - icon_url: "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" + icon_url: + "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" }, footer: { icon_url: "https://i.imgur.com/yWf5USu.png", @@ -103,7 +109,8 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, author: { - icon_url: "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" + icon_url: + "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" }, footer: { icon_url: "https://i.imgur.com/yWf5USu.png", @@ -117,7 +124,8 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, author: { - icon_url: "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" + icon_url: + "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" }, footer: { icon_url: "https://i.imgur.com/yWf5USu.png", @@ -131,7 +139,8 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, author: { - icon_url: "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" + icon_url: + "http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png" }, footer: { icon_url: "https://i.imgur.com/yWf5USu.png", diff --git a/bot/modules/rolesetter.js b/bot/modules/rolesetter.js index 05ad91b..589721f 100644 --- a/bot/modules/rolesetter.js +++ b/bot/modules/rolesetter.js @@ -23,33 +23,39 @@ exports.addrole = { //console.log(rolelist.allowedroles); //console.log(config.get('allowedroles')); if (suffix) { - if (rolelist.allowedroles.includes(suffix)) { - //console.log('Role is in allowed roles.'); - //console.log('Role to add: ' + newrole); - if (!msg.member.roles.find("name", suffix)) { - msg.member - .addRole(newrole) - .then( - msg.channel.send( - msg.member + " has been added to the " + suffix + " role!" - ) - ); - //console.log('Added role') - //msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!'); - } 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( - "That role isn't one you can add yourself too! Please run the " + botconfig.prefix + "roles command to find out which ones are allowed." + if (rolelist.allowedroles.includes(suffix)) { + //console.log('Role is in allowed roles.'); + //console.log('Role to add: ' + newrole); + if (!msg.member.roles.find("name", suffix)) { + msg.member + .addRole(newrole) + .then( + msg.channel.send( + msg.member + " has been added to the " + suffix + " role!" + ) ); + //console.log('Added role') + //msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!'); + } 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( + "That role isn't one you can add yourself too! 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!" - ) + msg.channel.send( + "Please specify a role. Type " + + botconfig.prefix + + "roles to see which you may add!" + ); } } }; @@ -64,29 +70,35 @@ exports.delrole = { //console.log(msg); //console.log('Printing Suffix! ' + suffix); if (suffix) { - if (rolelist.allowedroles.includes(suffix)) { - 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( - "That role isn't one you can add yourself too! Please run the " + botconfig.prefix + "roles command to find out which ones are allowed." + if (rolelist.allowedroles.includes(suffix)) { + 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 { + } else { msg.channel.send( - "Please specify a role. Type " + botconfig.prefix + "roles to see which you may add!" - ) + "That role isn't one you can add yourself too! 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!" + ); } } }; diff --git a/bot/plugins.js b/bot/plugins.js index 86c5ea8..ee4ef32 100644 --- a/bot/plugins.js +++ b/bot/plugins.js @@ -1,12 +1,12 @@ -"use strict"; +'use strict'; -const fs = require("fs"), - path = require("path"); +const fs = require('fs'), + path = require('path'); function getPlugins(srcpath) { return fs.readdirSync(srcpath); } -let plugin_directory = path.join(__dirname, "modules"); +let plugin_directory = path.join(__dirname, 'modules'); let plugins = getPlugins(plugin_directory); exports.init = function init() { @@ -14,7 +14,7 @@ exports.init = function init() { }; function load_plugins() { - const dbot = require("./bot.js"); + const dbot = require('./bot.js'); let commandCount = 0; let otherFunc = 0; for (let i = 0; i < plugins.length; i++) { @@ -25,7 +25,7 @@ function load_plugins() { console.log(`Improper setup of the '${plugins[i]}' plugin. : ${err}`); } if (plugin) { - if ("commands" in plugin) { + if ('commands' in plugin) { for (let j = 0; j < plugin.commands.length; j++) { if (plugin.commands[j] in plugin) { dbot.addCommand(plugin.commands[j], plugin[plugin.commands[j]]); @@ -33,7 +33,7 @@ function load_plugins() { } } } - if ("custom" in plugin) { + if ('custom' in plugin) { for (let j = 0; j < plugin.custom.length; j++) { if (plugin.custom[j] in plugin) { dbot.addCustomFunc(plugin[plugin.custom[j]]); @@ -43,9 +43,5 @@ function load_plugins() { } } } - console.log( - `Loaded ${dbot.commandCount()} chat commands and ${ - otherFunc - } custom functions.` - ); + console.log(`Loaded ${dbot.commandCount()} chat commands and ${otherFunc} custom functions.`); }