armonize prettier config with tipbot

This commit is contained in:
Niko Storni 2018-03-28 18:32:03 -04:00
parent 9db8e164ce
commit f3dc3c0356
No known key found for this signature in database
GPG key ID: F37FE63398800368
19 changed files with 1502 additions and 1768 deletions

View file

@ -62,11 +62,7 @@ function checkMessageForCommand(msg, isEdit) {
//check if message is a command //check if message is a command
if (msg.author.id != bot.user.id && msg.content.startsWith(config.prefix)) { if (msg.author.id != bot.user.id && msg.content.startsWith(config.prefix)) {
//check if user is Online //check if user is Online
if ( if (!msg.author.presence.status || msg.author.presence.status == 'offline' || msg.author.presence.status == 'invisible') {
!msg.author.presence.status ||
msg.author.presence.status == 'offline' ||
msg.author.presence.status == 'invisible'
) {
msg.channel.send('Please set your Discord Presence to Online to talk to the Bot!'); msg.channel.send('Please set your Discord Presence to Online to talk to the Bot!');
return; return;
} }

View file

@ -1,89 +1,66 @@
let needle = require("needle"); let needle = require('needle');
let hasPriceBotChannels = require("../helpers.js").hasPriceBotChannels; let hasPriceBotChannels = require('../helpers.js').hasPriceBotChannels;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let config = require("config"); let config = require('config');
let ChannelID = config.get("pricebot").mainchannel; let ChannelID = config.get('pricebot').mainchannel;
exports.commands = ["altprice"]; exports.commands = ['altprice'];
exports.altprice = { exports.altprice = {
usage: "<coin> <fiat/coin> <amount>", usage: '<coin> <fiat/coin> <amount>',
description: description: 'display price of specified alt coin from crypto compare\n**Example:** *!altprice ETH USD 100*',
"display price of specified alt coin from crypto compare\n**Example:** *!altprice ETH USD 100*",
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
let dt = new Date(); let dt = new Date();
let timestamp = dt.toUTCString(); let timestamp = dt.toUTCString();
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) { if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send( msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
"Please use <#" + ChannelID + "> or DMs to talk to price bot."
);
return; return;
} }
if (suffix !== "") { if (suffix !== '') {
words = suffix words = suffix
.trim() .trim()
.split(" ") .split(' ')
.filter(function(n) { .filter(function(n) {
return n !== ""; return n !== '';
}); });
var currency1 = words[0].toUpperCase(); var currency1 = words[0].toUpperCase();
if (words[1] == undefined) { if (words[1] == undefined) {
var currency2 = "BTC"; var currency2 = 'BTC';
} else { } else {
var currency2 = words[1].toUpperCase(); var currency2 = words[1].toUpperCase();
} }
if (words[2] == undefined) { if (words[2] == undefined) {
var amount = "1"; var amount = '1';
} else { } else {
if (getValidatedAmount(words[2]) === null) { if (getValidatedAmount(words[2]) === null) {
msg.reply("Please specify a number for <amount>"); msg.reply('Please specify a number for <amount>');
return; return;
} }
var amount = words[2].toUpperCase(); var amount = words[2].toUpperCase();
} }
} else { } else {
var currency1 = "BTC"; var currency1 = 'BTC';
var currency2 = "USD"; var currency2 = 'USD';
var amount = "1"; var amount = '1';
} }
needle.get("https://min-api.cryptocompare.com/data/all/coinlist", function( needle.get('https://min-api.cryptocompare.com/data/all/coinlist', function(error, response) {
error,
response
) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available"); msg.channel.send('coinmarketcap API is not available');
} else { } else {
if (!response.body.Data.hasOwnProperty(currency1)) { if (!response.body.Data.hasOwnProperty(currency1)) {
msg.channel.send("Invalid Alt Coin"); msg.channel.send('Invalid Alt Coin');
return; return;
} }
needle.get( needle.get('https://min-api.cryptocompare.com/data/price?fsym=' + currency1 + '&tsyms=' + currency2, function(error, response) {
"https://min-api.cryptocompare.com/data/price?fsym=" + if (error || response.statusCode !== 200) {
currency1 + msg.channel.send('coinmarketcap API is not available');
"&tsyms=" + } else {
currency2, var price = Number(response.body[currency2]);
function(error, response) { var newprice = price * amount;
if (error || response.statusCode !== 200) { var message = amount + ' ' + currency1 + ' = ' + newprice.toFixed(8) + ' ' + currency2 + '\n' + '*Updated: ' + timestamp + '*';
msg.channel.send("coinmarketcap API is not available"); msg.channel.send(message);
} else {
var price = Number(response.body[currency2]);
var newprice = price * amount;
var message =
amount +
" " +
currency1 +
" = " +
newprice.toFixed(8) +
" " +
currency2 +
"\n" +
"*Updated: " +
timestamp +
"*";
msg.channel.send(message);
}
} }
); });
} }
}); });
function getValidatedAmount(amount) { function getValidatedAmount(amount) {

View file

@ -1,14 +1,14 @@
"use strict"; 'use strict';
let lbry; let lbry;
let mongo; let mongo;
let discordBot; let discordBot;
let moment = require("moment"); let moment = require('moment');
let request = require("request"); let request = require('request');
let sleep = require("sleep"); let sleep = require('sleep');
let config = require("config"); let config = require('config');
let channels = config.get("claimbot").channels; let channels = config.get('claimbot').channels;
const Discord = require("discord.js"); const Discord = require('discord.js');
module.exports = { module.exports = {
init: init init: init
@ -16,23 +16,23 @@ module.exports = {
function init(discordBot_) { function init(discordBot_) {
if (lbry) { if (lbry) {
throw new Error("init was already called once"); throw new Error('init was already called once');
} }
discordBot = discordBot_; discordBot = discordBot_;
const MongoClient = require("mongodb").MongoClient; const MongoClient = require('mongodb').MongoClient;
MongoClient.connect(config.get("mongodb").url, function(err, db) { MongoClient.connect(config.get('mongodb').url, function(err, db) {
if (err) { if (err) {
throw err; throw err;
} }
mongo = db; mongo = db;
const bitcoin = require("bitcoin"); const bitcoin = require('bitcoin');
lbry = new bitcoin.Client(config.get("lbrycrd")); lbry = new bitcoin.Client(config.get('lbrycrd'));
console.log("Activating claimbot "); console.log('Activating claimbot ');
discordBot.channels.get(channels[0]).send("activating claimbot"); discordBot.channels.get(channels[0]).send('activating claimbot');
setInterval(function() { setInterval(function() {
announceNewClaims(); announceNewClaims();
@ -43,25 +43,21 @@ function init(discordBot_) {
function announceNewClaims() { function announceNewClaims() {
if (!mongo) { if (!mongo) {
discordPost("Failed to connect to mongo", {}); discordPost('Failed to connect to mongo', {});
return; return;
} }
if (!lbry) { if (!lbry) {
discordPost("Failed to connect to lbrycrd", {}); discordPost('Failed to connect to lbrycrd', {});
return; return;
} }
Promise.all([getLastBlock(), lbryCall("getinfo")]) Promise.all([getLastBlock(), lbryCall('getinfo')])
.then(function([lastProcessedBlock, currentBlockInfo]) { .then(function([lastProcessedBlock, currentBlockInfo]) {
const currentHeight = currentBlockInfo["blocks"]; const currentHeight = currentBlockInfo['blocks'];
console.log(currentHeight); console.log(currentHeight);
if (lastProcessedBlock === null) { if (lastProcessedBlock === null) {
console.log( console.log('First run. Setting last processed block to ' + currentHeight + ' and exiting.');
"First run. Setting last processed block to " +
currentHeight +
" and exiting."
);
return setLastBlock(currentHeight); return setLastBlock(currentHeight);
} }
@ -71,14 +67,8 @@ function announceNewClaims() {
const firstBlockToProcess = testBlock || lastProcessedBlock + 1, const firstBlockToProcess = testBlock || lastProcessedBlock + 1,
lastBlockToProcess = testBlock || currentHeight; lastBlockToProcess = testBlock || currentHeight;
console.log( console.log('Doing blocks ' + firstBlockToProcess + ' to ' + lastBlockToProcess);
"Doing blocks " + firstBlockToProcess + " to " + lastBlockToProcess return announceClaimsLoop(firstBlockToProcess, lastBlockToProcess, currentHeight);
);
return announceClaimsLoop(
firstBlockToProcess,
lastBlockToProcess,
currentHeight
);
} }
}) })
.catch(function(err) { .catch(function(err) {
@ -88,27 +78,24 @@ function announceNewClaims() {
function announceClaimsLoop(block, lastBlock, currentHeight) { function announceClaimsLoop(block, lastBlock, currentHeight) {
let claimsFound = 0; let claimsFound = 0;
return lbryCall("getblockhash", block) return lbryCall('getblockhash', block)
.then(function(blockHash) { .then(function(blockHash) {
return lbryCall("getblock", blockHash); return lbryCall('getblock', blockHash);
}) })
.then(function(blockData) { .then(function(blockData) {
return Promise.all(blockData["tx"].map(getClaimsForTxid)); return Promise.all(blockData['tx'].map(getClaimsForTxid));
}) })
.then(function(arrayOfClaimArrays) { .then(function(arrayOfClaimArrays) {
const claims = Array.prototype const claims = Array.prototype.concat(...arrayOfClaimArrays).filter(function(c) {
.concat(...arrayOfClaimArrays) return !!c;
.filter(function(c) { });
return !!c; console.log('Found ' + claims.length + ' claims in ' + block);
});
console.log("Found " + claims.length + " claims in " + block);
claimsFound = claims.length; claimsFound = claims.length;
return Promise.all( return Promise.all(
claims.map(function(claim) { claims.map(function(claim) {
//the API has a rate limit. to avoid hitting it we must have a small delay between each message //the API has a rate limit. to avoid hitting it we must have a small delay between each message
//if claims were found in this block, then we wait, otherwise we don't //if claims were found in this block, then we wait, otherwise we don't
if (claimsFound > 0 && claim.hasOwnProperty("claimId")) if (claimsFound > 0 && claim.hasOwnProperty('claimId')) sleep.msleep(300);
sleep.msleep(300);
return announceClaim(claim, block, currentHeight); return announceClaim(claim, block, currentHeight);
}) })
); );
@ -125,17 +112,17 @@ function announceClaimsLoop(block, lastBlock, currentHeight) {
} }
function announceClaim(claim, claimBlockHeight, currentHeight) { function announceClaim(claim, claimBlockHeight, currentHeight) {
console.log("" + claimBlockHeight + ": New claim for " + claim["name"]); console.log('' + claimBlockHeight + ': New claim for ' + claim['name']);
console.log(claim); console.log(claim);
//ignore supports for now //ignore supports for now
//the issue with supports is that they should be treated completely differently //the issue with supports is that they should be treated completely differently
//they are not new claims... //they are not new claims...
if (claim.hasOwnProperty("supported claimId")) return; if (claim.hasOwnProperty('supported claimId')) return;
let options = { let options = {
method: "GET", method: 'GET',
url: "http://127.0.0.1:5000/claim_decode/" + claim["name"] url: 'http://127.0.0.1:5000/claim_decode/' + claim['name']
}; };
request(options, function(error, response, body) { request(options, function(error, response, body) {
@ -146,30 +133,22 @@ function announceClaim(claim, claimBlockHeight, currentHeight) {
let channelName = null; let channelName = null;
try { try {
body = JSON.parse(body); body = JSON.parse(body);
if ( if (body.hasOwnProperty('stream') && body.stream.hasOwnProperty('metadata')) {
body.hasOwnProperty("stream") &&
body.stream.hasOwnProperty("metadata")
) {
claimData = body.stream.metadata; claimData = body.stream.metadata;
channelName = body.hasOwnProperty("channel_name") channelName = body.hasOwnProperty('channel_name') ? body['channel_name'] : null;
? body["channel_name"]
: null;
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
return; return;
} }
return Promise.all([ return Promise.all([lbryCall('getvalueforname', claim['name']), lbryCall('getclaimsforname', claim['name'])]).then(function([currentWinningClaim, claimsForName]) {
lbryCall("getvalueforname", claim["name"]),
lbryCall("getclaimsforname", claim["name"])
]).then(function([currentWinningClaim, claimsForName]) {
//console.log(JSON.stringify(claimData)); //console.log(JSON.stringify(claimData));
let value = null; let value = null;
if (claimData !== null) value = claimData; if (claimData !== null) value = claimData;
else { else {
try { try {
value = JSON.parse(claim["value"]); value = JSON.parse(claim['value']);
} catch (e) {} } catch (e) {}
} }
@ -183,74 +162,52 @@ function announceClaim(claim, claimBlockHeight, currentHeight) {
else else
*/ */
console.log(value); console.log(value);
if (value["author"]) { if (value['author']) {
text.push("author: " + value["author"]); text.push('author: ' + value['author']);
} }
if (value["description"]) { if (value['description']) {
text.push(value["description"]); text.push(value['description']);
} }
// if (value['content_type']) // if (value['content_type'])
// { // {
// text.push("*Content Type:* " + value['content_type']); // text.push("*Content Type:* " + value['content_type']);
// } // }
if (value["nsfw"]) { if (value['nsfw']) {
text.push("*Warning: Adult Content*"); text.push('*Warning: Adult Content*');
} }
//"fee":{"currency":"LBC","amount":186,"version":"_0_0_1","address":"bTGoFCakvQXvBrJg1b7FJzombFUu6iRJsk"} //"fee":{"currency":"LBC","amount":186,"version":"_0_0_1","address":"bTGoFCakvQXvBrJg1b7FJzombFUu6iRJsk"}
if (value["fee"]) { if (value['fee']) {
const fees = []; const fees = [];
text.push( text.push('Price: ' + value['fee'].amount + ' *' + value['fee'].currency + '*');
"Price: " +
value["fee"].amount +
" *" +
value["fee"].currency +
"*"
);
} }
if (!claim["is controlling"]) { if (!claim['is controlling']) {
// the following is based on https://lbry.io/faq/claimtrie-implementation // the following is based on https://lbry.io/faq/claimtrie-implementation
const lastTakeoverHeight = claimsForName["nLastTakeoverHeight"], const lastTakeoverHeight = claimsForName['nLastTakeoverHeight'],
maxDelay = 4032, // 7 days of blocks at 2.5min per block maxDelay = 4032, // 7 days of blocks at 2.5min per block
activationDelay = Math.min( activationDelay = Math.min(maxDelay, Math.floor((claimBlockHeight - lastTakeoverHeight) / 32)),
maxDelay,
Math.floor((claimBlockHeight - lastTakeoverHeight) / 32)
),
takeoverHeight = claimBlockHeight + activationDelay, takeoverHeight = claimBlockHeight + activationDelay,
secondsPerBlock = 161, // in theory this should be 150, but in practice its closer to 161 secondsPerBlock = 161, // in theory this should be 150, but in practice its closer to 161
takeoverTime = takeoverTime = Date.now() + (takeoverHeight - currentHeight) * secondsPerBlock * 1000;
Date.now() +
(takeoverHeight - currentHeight) * secondsPerBlock * 1000;
text.push( text.push('Takes effect on approx. **' + moment(takeoverTime, 'x').format('MMMM Do [at] HH:mm [UTC]') + '** (block ' + takeoverHeight + ')');
"Takes effect on approx. **" +
moment(takeoverTime, "x").format("MMMM Do [at] HH:mm [UTC]") +
"** (block " +
takeoverHeight +
")"
);
} }
const richEmbeded = { const richEmbeded = {
author: { author: {
name: value["author"] || "Anonymous", name: value['author'] || 'Anonymous',
url: "http://open.lbry.io/" + claim["name"], url: 'http://open.lbry.io/' + claim['name'],
icon_url: icon_url: 'http://barkpost-assets.s3.amazonaws.com/wp-content/uploads/2013/11/3dDoge.gif'
"http://barkpost-assets.s3.amazonaws.com/wp-content/uploads/2013/11/3dDoge.gif"
}, },
title: title: 'lbry://' + (channelName ? channelName + '/' : '') + claim['name'],
"lbry://" +
(channelName ? channelName + "/" : "") +
claim["name"],
color: 1399626, color: 1399626,
description: escapeSlackHtml(text.join("\n")), description: escapeSlackHtml(text.join('\n')),
footer: { footer: {
text: text: 'Block ' + claimBlockHeight + ' • Claim ID ' + claim['claimId']
"Block " + claimBlockHeight + " • Claim ID " + claim["claimId"]
}, },
image: { url: !value["nsfw"] ? value["thumbnail"] || "" : "" }, image: { url: !value['nsfw'] ? value['thumbnail'] || '' : '' },
url: "http://open.lbry.io/" + claim["name"] url: 'http://open.lbry.io/' + claim['name']
}; };
discordPost(text, richEmbeded); discordPost(text, richEmbeded);
@ -264,13 +221,13 @@ function announceClaim(claim, claimBlockHeight, currentHeight) {
function escapeSlackHtml(txt) { function escapeSlackHtml(txt) {
return txt return txt
.replace("&", "&amp;") .replace('&', '&amp;')
.replace("<", "&lt;") .replace('<', '&lt;')
.replace(">", "&gt;"); .replace('>', '&gt;');
} }
function getClaimsForTxid(txid) { function getClaimsForTxid(txid) {
return lbryCall("getclaimsfortx", txid).catch(function(err) { return lbryCall('getclaimsfortx', txid).catch(function(err) {
// an error here most likely means the transaction is spent, // an error here most likely means the transaction is spent,
// which also means there are no claims worth looking at // which also means there are no claims worth looking at
return []; return [];
@ -279,13 +236,11 @@ function getClaimsForTxid(txid) {
function getLastBlock() { function getLastBlock() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
mongo.collection("claimbot").findOne({}, function(err, obj) { mongo.collection('claimbot').findOne({}, function(err, obj) {
if (err) { if (err) {
reject(err); reject(err);
} else if (!obj) { } else if (!obj) {
mongo mongo.collection('claimbot').createIndex({ last_block: 1 }, { unique: true });
.collection("claimbot")
.createIndex({ last_block: 1 }, { unique: true });
resolve(null); resolve(null);
} else { } else {
resolve(obj.last_block); resolve(obj.last_block);
@ -296,25 +251,13 @@ function getLastBlock() {
function setLastBlock(block) { function setLastBlock(block) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
mongo mongo.collection('claimbot').findOneAndUpdate({ last_block: { $exists: true } }, { last_block: block }, { upsert: true, returnOriginal: false }, function(err, obj) {
.collection("claimbot") if (!err && obj && obj.value.last_block != block) {
.findOneAndUpdate( reject('Last value should be ' + block + ', but it is ' + obj.value.last_block);
{ last_block: { $exists: true } }, } else {
{ last_block: block }, resolve();
{ upsert: true, returnOriginal: false }, }
function(err, obj) { });
if (!err && obj && obj.value.last_block != block) {
reject(
"Last value should be " +
block +
", but it is " +
obj.value.last_block
);
} else {
resolve();
}
}
);
}); });
} }
@ -324,7 +267,7 @@ function discordPost(text, params) {
channels.forEach(channel => { channels.forEach(channel => {
discordBot.channels discordBot.channels
.get(channel) .get(channel)
.send("", richEmbeded) .send('', richEmbeded)
.catch(console.error); .catch(console.error);
}); });
} }
@ -333,9 +276,7 @@ function lbryCall(...args) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
lbry.cmd(...args, function(err, ...response) { lbry.cmd(...args, function(err, ...response) {
if (err) { if (err) {
reject( reject(new Error('JSONRPC call failed. Args: [' + args.join(', ') + ']'));
new Error("JSONRPC call failed. Args: [" + args.join(", ") + "]")
);
} else { } else {
resolve(...response); resolve(...response);
} }

View file

@ -1,6 +1,6 @@
"use strict"; 'use strict';
let commands = require("../../config/commands"); let commands = require('../../config/commands');
const Discord = require("discord.js"); const Discord = require('discord.js');
let initialized = false; let initialized = false;
let discordBot = null; let discordBot = null;
let commandsList = null; let commandsList = null;
@ -11,12 +11,12 @@ module.exports = {
function init(discordBot_) { function init(discordBot_) {
if (initialized) { if (initialized) {
throw new Error("init was already called once"); throw new Error('init was already called once');
} }
discordBot = discordBot_; discordBot = discordBot_;
discordBot.on("message", checkForCommand); discordBot.on('message', checkForCommand);
} }
/** /**
@ -28,31 +28,24 @@ let checkForCommand = function(message) {
let firstRun = false; let firstRun = false;
if (commandsList === null) { if (commandsList === null) {
firstRun = true; firstRun = true;
commandsList = ""; commandsList = '';
} }
//for each message go through all the commands and check if there are any matches //for each message go through all the commands and check if there are any matches
Object.keys(commands).forEach(command => { Object.keys(commands).forEach(command => {
//during the first run also build the cache //during the first run also build the cache
if (firstRun) commandsList += command + ", "; if (firstRun) commandsList += command + ', ';
//if a command is found //if a command is found
if ( if (!message.author.bot && message.content.toLowerCase().indexOf(command.toLowerCase()) >= 0 && commands[command].operation === 'send') {
!message.author.bot &&
message.content.toLowerCase().indexOf(command.toLowerCase()) >= 0 &&
commands[command].operation === "send"
) {
//send a message to the channel according to the config //send a message to the channel according to the config
message.channel.send("", new Discord.RichEmbed(commands[command].bundle)); message.channel.send('', new Discord.RichEmbed(commands[command].bundle));
} }
}); });
//if the user is requesting the list of commands, then print it //if the user is requesting the list of commands, then print it
if ( if (!message.author.bot && message.content.toLowerCase().indexOf('!helpcommands') >= 0) {
!message.author.bot && let bundle = commands['!helpcommands'].bundle;
message.content.toLowerCase().indexOf("!helpcommands") >= 0 commandsList = commandsList.replace(/,\s$/g, '');
) { bundle.description = '**' + commandsList + '**';
let bundle = commands["!helpcommands"].bundle; message.channel.send('', new Discord.RichEmbed(bundle));
commandsList = commandsList.replace(/,\s$/g, "");
bundle.description = "**" + commandsList + "**";
message.channel.send("", new Discord.RichEmbed(bundle));
} }
}; };

View file

@ -1,13 +1,13 @@
let needle = require("needle"); let needle = require('needle');
let config = require("config"); let config = require('config');
let hasHashBotChannels = require("../helpers.js").hasHashBotChannels; let hasHashBotChannels = require('../helpers.js').hasHashBotChannels;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get("hashbot").mainchannel; let ChannelID = config.get('hashbot').mainchannel;
exports.commands = [ exports.commands = [
"hash" // command that is in this file, every command needs it own export as shown below 'hash' // command that is in this file, every command needs it own export as shown below
]; ];
exports.custom = ["timedhash"]; exports.custom = ['timedhash'];
exports.timedhash = function(bot) { exports.timedhash = function(bot) {
setInterval(function() { setInterval(function() {
@ -15,55 +15,49 @@ exports.timedhash = function(bot) {
}, 6 * 60 * 60 * 1000); }, 6 * 60 * 60 * 1000);
function sendMiningInfo(bot) { function sendMiningInfo(bot) {
needle.get("https://explorer.lbry.io/api/v1/status", function( needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
error,
response
) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("Explorer API is not available"); msg.channel.send('Explorer API is not available');
} else { } else {
var data = response.body; var data = response.body;
var height = Number(data.status.height); var height = Number(data.status.height);
var hashrate = data.status.hashrate; var hashrate = data.status.hashrate;
var difficulty = Number(data.status.difficulty); var difficulty = Number(data.status.difficulty);
needle.get("https://whattomine.com/coins/164.json", function( needle.get('https://whattomine.com/coins/164.json', function(error, response) {
error,
response
) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("whattomine API is not available"); msg.channel.send('whattomine API is not available');
} }
var data = response.body; var data = response.body;
var reward = Number(data.block_reward); var reward = Number(data.block_reward);
var block_time = Number(data.block_time); var block_time = Number(data.block_time);
var difficulty24 = Number(data.difficulty24); var difficulty24 = Number(data.difficulty24);
description = description =
"Hashrate: " + 'Hashrate: ' +
numberWithCommas(hashrate) + numberWithCommas(hashrate) +
"\n" + '\n' +
"Difficulty: " + 'Difficulty: ' +
numberWithCommas(difficulty.toFixed(0)) + numberWithCommas(difficulty.toFixed(0)) +
"\n" + '\n' +
"Difficulty 24 Hour Average: " + 'Difficulty 24 Hour Average: ' +
numberWithCommas(difficulty24.toFixed(0)) + numberWithCommas(difficulty24.toFixed(0)) +
"\n" + '\n' +
"Current block: " + 'Current block: ' +
numberWithCommas(height.toFixed(0)) + numberWithCommas(height.toFixed(0)) +
"\n" + '\n' +
"Block Time: " + 'Block Time: ' +
numberWithCommas(block_time.toFixed(0)) + numberWithCommas(block_time.toFixed(0)) +
" seconds \n" + ' seconds \n' +
"Block Reward: " + 'Block Reward: ' +
numberWithCommas(reward.toFixed(0)) + numberWithCommas(reward.toFixed(0)) +
" LBC \n" + ' LBC \n' +
"Sources: https://explorer.lbry.io & \n" + 'Sources: https://explorer.lbry.io & \n' +
"https://whattomine.com/coins/164-lbc-lbry"; 'https://whattomine.com/coins/164-lbc-lbry';
const embed = { const embed = {
description: description, description: description,
color: 7976557, color: 7976557,
author: { author: {
name: "LBRY Network Stats", name: 'LBRY Network Stats',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
}; };
bot.channels.get(ChannelID).send({ embed }); bot.channels.get(ChannelID).send({ embed });
@ -72,26 +66,25 @@ exports.timedhash = function(bot) {
} }
}); });
function numberWithCommas(x) { function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} }
} }
}; };
exports.hash = { exports.hash = {
usage: "", usage: '',
description: description: 'Displays current Hashrate of Network\n**!hash power <Mh/s>**\n Displays potential Earnings For Given Hashrate',
"Displays current Hashrate of Network\n**!hash power <Mh/s>**\n Displays potential Earnings For Given Hashrate",
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
var command = "!hash"; var command = '!hash';
words = suffix words = suffix
.trim() .trim()
.split(" ") .split(' ')
.filter(function(n) { .filter(function(n) {
return n !== ""; return n !== '';
}); });
profitcommand = words[0]; profitcommand = words[0];
myhashrate = words[1]; myhashrate = words[1];
if (profitcommand == "power") { if (profitcommand == 'power') {
sendProfitInfo(bot, msg, suffix); sendProfitInfo(bot, msg, suffix);
return; return;
} else { } else {
@ -101,60 +94,52 @@ exports.hash = {
function sendMiningInfo(bot, msg, suffix) { function sendMiningInfo(bot, msg, suffix) {
if (!inPrivate(msg) && !hasHashBotChannels(msg)) { if (!inPrivate(msg) && !hasHashBotChannels(msg)) {
msg.channel.send( msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to hash bot.');
"Please use <#" + ChannelID + "> or DMs to talk to hash bot."
);
return; return;
} }
needle.get("https://explorer.lbry.io/api/v1/status", function( needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
error,
response
) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("Explorer API is not available"); msg.channel.send('Explorer API is not available');
} else { } else {
var data = response.body; var data = response.body;
var height = Number(data.status.height); var height = Number(data.status.height);
var hashrate = data.status.hashrate; var hashrate = data.status.hashrate;
var difficulty = Number(data.status.difficulty); var difficulty = Number(data.status.difficulty);
needle.get("https://whattomine.com/coins/164.json", function( needle.get('https://whattomine.com/coins/164.json', function(error, response) {
error,
response
) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("whattomine API is not available"); msg.channel.send('whattomine API is not available');
} }
var data = response.body; var data = response.body;
var reward = Number(data.block_reward); var reward = Number(data.block_reward);
var block_time = Number(data.block_time); var block_time = Number(data.block_time);
var difficulty24 = Number(data.difficulty24); var difficulty24 = Number(data.difficulty24);
description = description =
"Hashrate: " + 'Hashrate: ' +
numberWithCommas(hashrate) + numberWithCommas(hashrate) +
"\n" + '\n' +
"Difficulty: " + 'Difficulty: ' +
numberWithCommas(difficulty.toFixed(0)) + numberWithCommas(difficulty.toFixed(0)) +
"\n" + '\n' +
"Difficulty 24 Hour Average: " + 'Difficulty 24 Hour Average: ' +
numberWithCommas(difficulty24.toFixed(0)) + numberWithCommas(difficulty24.toFixed(0)) +
"\n" + '\n' +
"Current block: " + 'Current block: ' +
numberWithCommas(height.toFixed(0)) + numberWithCommas(height.toFixed(0)) +
"\n" + '\n' +
"Block Time: " + 'Block Time: ' +
numberWithCommas(block_time.toFixed(0)) + numberWithCommas(block_time.toFixed(0)) +
" seconds \n" + ' seconds \n' +
"Block Reward: " + 'Block Reward: ' +
numberWithCommas(reward.toFixed(0)) + numberWithCommas(reward.toFixed(0)) +
" LBC \n" + ' LBC \n' +
"Sources: https://explorer.lbry.io & \n" + 'Sources: https://explorer.lbry.io & \n' +
"https://whattomine.com/coins/164-lbc-lbry"; 'https://whattomine.com/coins/164-lbc-lbry';
const embed = { const embed = {
description: description, description: description,
color: 7976557, color: 7976557,
author: { author: {
name: "LBRY Network Stats", name: 'LBRY Network Stats',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
}; };
msg.channel.send({ embed }); msg.channel.send({ embed });
@ -164,27 +149,19 @@ exports.hash = {
}); });
} }
function sendProfitInfo(bot, msg, suffix) { function sendProfitInfo(bot, msg, suffix) {
needle.get("https://whattomine.com/coins/164.json", function( needle.get('https://whattomine.com/coins/164.json', function(error, response) {
error,
response
) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("whattomine API is not available"); msg.channel.send('whattomine API is not available');
} else { } else {
words = suffix words = suffix
.trim() .trim()
.split(" ") .split(' ')
.filter(function(n) { .filter(function(n) {
return n !== ""; return n !== '';
}); });
var myhashrate = words[1]; var myhashrate = words[1];
if ( if (myhashrate == '' || myhashrate == null || myhashrate == undefined || myhashrate == ' ') {
myhashrate == "" || myhashrate = '100';
myhashrate == null ||
myhashrate == undefined ||
myhashrate == " "
) {
myhashrate = "100";
} }
var Diff = response.body.difficulty24; var Diff = response.body.difficulty24;
var Reward = response.body.block_reward; var Reward = response.body.block_reward;
@ -192,33 +169,32 @@ exports.hash = {
var LBC = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 3600; var LBC = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 3600;
var LBC24 = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 86400; var LBC24 = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 86400;
var LBC1w = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 604800; var LBC1w = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 604800;
var LBC1m = var LBC1m = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 2628000;
myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 2628000;
var message = var message =
"With **" + 'With **' +
myHash + myHash +
" Mh/s** and Average 24 hour Difficulty: **" + ' Mh/s** and Average 24 hour Difficulty: **' +
Diff.toFixed(0) + Diff.toFixed(0) +
"**\n" + '**\n' +
"You can potentially earn the following amounts of **LBC**: \n" + 'You can potentially earn the following amounts of **LBC**: \n' +
"1 Hour = **" + '1 Hour = **' +
LBC.toFixed(4) + LBC.toFixed(4) +
"** \n" + '** \n' +
"1 Day = **" + '1 Day = **' +
LBC24.toFixed(2) + LBC24.toFixed(2) +
"** \n" + '** \n' +
"1 Week = **" + '1 Week = **' +
LBC1w.toFixed(4) + LBC1w.toFixed(4) +
"** \n" + '** \n' +
"1 Month = **" + '1 Month = **' +
LBC1m.toFixed(4) + LBC1m.toFixed(4) +
"** \n"; '** \n';
const embed = { const embed = {
description: message, description: message,
color: 7976557, color: 7976557,
author: { author: {
name: "Hashing Power Calculator!", name: 'Hashing Power Calculator!',
icon_url: "https://i.imgur.com/nKHVQgq.png" icon_url: 'https://i.imgur.com/nKHVQgq.png'
} }
}; };
msg.channel.send({ embed }); msg.channel.send({ embed });
@ -227,7 +203,7 @@ exports.hash = {
}); });
} }
function numberWithCommas(x) { function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} }
} }
}; };

View file

@ -1,7 +1,7 @@
const discordIRC = require("elmadev-discord-irc").default; const discordIRC = require('elmadev-discord-irc').default;
const config = require("config"); const config = require('config');
const ircconfig = config.get("irc"); const ircconfig = config.get('irc');
exports.custom = ["irc"]; exports.custom = ['irc'];
exports.irc = function(bot) { exports.irc = function(bot) {
discordIRC([ircconfig]); discordIRC([ircconfig]);

View file

@ -1,87 +1,85 @@
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let responseDebug = false; let responseDebug = false;
exports.custom = [ exports.custom = [
"lbrylink" //change this to your function name 'lbrylink' //change this to your function name
]; ];
exports.lbrylink = function(bot, msg, suffix) { exports.lbrylink = function(bot, msg, suffix) {
bot.on("message", msg => { bot.on('message', msg => {
if (inPrivate(msg)) { if (inPrivate(msg)) {
return; return;
} }
if (msg.content.includes("lbry://")) { if (msg.content.includes('lbry://')) {
//Extract URL from Message //Extract URL from Message
newURL = msg.content newURL = msg.content
.replace("lbry://", "https://open.lbry.io/") .replace('lbry://', 'https://open.lbry.io/')
.match(/\bhttps?:\/\/\S+/gi) .match(/\bhttps?:\/\/\S+/gi)
.toString(); .toString();
if (responseDebug) { if (responseDebug) {
console.log("___________________________"); console.log('___________________________');
console.log("newURL = " + newURL); console.log('newURL = ' + newURL);
} }
//Check if just lbry:// was supplied //Check if just lbry:// was supplied
if (newURL == "https://open.lbry.io/") { if (newURL == 'https://open.lbry.io/') {
return; return;
} }
//Check if Username Was Supplied //Check if Username Was Supplied
if (newURL.includes(">")) { if (newURL.includes('>')) {
//Get rid of ID from message //Get rid of ID from message
parseID = newURL.split(">").pop(); parseID = newURL.split('>').pop();
newURL = "https://open.lbry.io" + parseID; newURL = 'https://open.lbry.io' + parseID;
if (responseDebug) { if (responseDebug) {
console.log("Username Provided!"); console.log('Username Provided!');
console.log("parseID = " + parseID); console.log('parseID = ' + parseID);
console.log("newURL = " + newURL); console.log('newURL = ' + newURL);
} }
//check if just Username Was Supplied //check if just Username Was Supplied
if (!newURL.substr(20).includes("/")) { if (!newURL.substr(20).includes('/')) {
return; return;
} }
//check if more than username was supplied //check if more than username was supplied
//Also check obscurity in username like ``@MSFTserver` vs `@MSFTserverPics` //Also check obscurity in username like ``@MSFTserver` vs `@MSFTserverPics`
if (parseID.includes("/")) { if (parseID.includes('/')) {
//parse out extra params before `/` like `<@123456789>Pics` //parse out extra params before `/` like `<@123456789>Pics`
parseID = parseID.split("/").pop(); parseID = parseID.split('/').pop();
newURL = "https://open.lbry.io/" + parseID; newURL = 'https://open.lbry.io/' + parseID;
if (responseDebug) { if (responseDebug) {
console.log("Username no / check"); console.log('Username no / check');
console.log("parseID = " + parseID); console.log('parseID = ' + parseID);
console.log("newURL = " + newURL); console.log('newURL = ' + newURL);
} }
//checks if username had if after it or just blank to be safe //checks if username had if after it or just blank to be safe
if (newURL == "https://open.lbry.io/" || parseID.startsWith("#")) { if (newURL == 'https://open.lbry.io/' || parseID.startsWith('#')) {
return; return;
} }
} }
//one last saftey check //one last saftey check
if (newURL == "https://open.lbry.io") { if (newURL == 'https://open.lbry.io') {
return; return;
} }
//If no UserName Found proceed //If no UserName Found proceed
} else { } else {
if (newURL == "https://open.lbry.io/") { if (newURL == 'https://open.lbry.io/') {
return; return;
} }
if (responseDebug) { if (responseDebug) {
console.log("___________________________"); console.log('___________________________');
console.log("newURL = " + newURL); console.log('newURL = ' + newURL);
} }
} }
const embed = { const embed = {
description: description: "I see you tried to post a LBRY URL, here's a friendly hyperlink to share and for others to access your content with a single click: \n" + newURL,
"I see you tried to post a LBRY URL, here's a friendly hyperlink to share and for others to access your content with a single click: \n" +
newURL,
color: 7976557, color: 7976557,
author: { author: {
name: "LBRY Linker", name: 'LBRY Linker',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
}; };
msg.channel.send({ embed }); msg.channel.send({ embed });

View file

@ -1,268 +1,265 @@
"use strict"; 'use strict';
let jp = require("jsonpath"); let jp = require('jsonpath');
let moment = require("moment"); let moment = require('moment');
let numeral = require("numeral"); let numeral = require('numeral');
let request = require("request"); let request = require('request');
let config = require("config"); let config = require('config');
let hasPriceBotChannels = require("../helpers.js").hasPriceBotChannels; let hasPriceBotChannels = require('../helpers.js').hasPriceBotChannels;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get("pricebot").mainchannel; let ChannelID = config.get('pricebot').mainchannel;
exports.commands = ["price"]; exports.commands = ['price'];
exports.price = { exports.price = {
usage: "<currency> <amount>", usage: '<currency> <amount>',
description: "displays price of lbc", description: 'displays price of lbc',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
var options = { var options = {
defaultCurrency: "BTC", defaultCurrency: 'BTC',
// supported currencies and api steps to arrive at the final value // supported currencies and api steps to arrive at the final value
currencies: { currencies: {
USD: { USD: {
steps: ["LBCBTC", "BTCUSD"], steps: ['LBCBTC', 'BTCUSD'],
format: "$0,0.00", format: '$0,0.00',
sign: "USD " sign: 'USD '
}, },
GBP: { GBP: {
steps: ["LBCBTC", "BTCGBP"], steps: ['LBCBTC', 'BTCGBP'],
format: "£0,0.00", format: '£0,0.00',
sign: "£" sign: '£'
}, },
AUD: { AUD: {
steps: ["LBCBTC", "BTCAUD"], steps: ['LBCBTC', 'BTCAUD'],
format: "$0,0.00", format: '$0,0.00',
sign: "AUD " sign: 'AUD '
}, },
BRL: { BRL: {
steps: ["LBCBTC", "BTCBRL"], steps: ['LBCBTC', 'BTCBRL'],
format: "R$0,0.00", format: 'R$0,0.00',
sign: "R$" sign: 'R$'
}, },
CAD: { CAD: {
steps: ["LBCBTC", "BTCCAD"], steps: ['LBCBTC', 'BTCCAD'],
format: "$0,0.00", format: '$0,0.00',
sign: "CAD " sign: 'CAD '
}, },
CHF: { CHF: {
steps: ["LBCBTC", "BTCCHF"], steps: ['LBCBTC', 'BTCCHF'],
format: "CHF 0,0.00", format: 'CHF 0,0.00',
sign: "CHF" sign: 'CHF'
}, },
CLP: { CLP: {
steps: ["LBCBTC", "BTCCLP"], steps: ['LBCBTC', 'BTCCLP'],
format: "$0,0.00", format: '$0,0.00',
sign: "CLP " sign: 'CLP '
}, },
CNY: { CNY: {
steps: ["LBCBTC", "BTCCNY"], steps: ['LBCBTC', 'BTCCNY'],
format: "¥0,0.00", format: '¥0,0.00',
sign: "¥" sign: '¥'
}, },
DKK: { DKK: {
steps: ["LBCBTC", "BTCDKK"], steps: ['LBCBTC', 'BTCDKK'],
format: "kr 0,0.00", format: 'kr 0,0.00',
sign: "kr" sign: 'kr'
}, },
EUR: { EUR: {
steps: ["LBCBTC", "BTCEUR"], steps: ['LBCBTC', 'BTCEUR'],
format: "€0,0.00", format: '€0,0.00',
sign: "€" sign: '€'
}, },
HKD: { HKD: {
steps: ["LBCBTC", "BTCHKD"], steps: ['LBCBTC', 'BTCHKD'],
format: "$0,0.00", format: '$0,0.00',
sign: "HKD " sign: 'HKD '
}, },
INR: { INR: {
steps: ["LBCBTC", "BTCINR"], steps: ['LBCBTC', 'BTCINR'],
format: "₹0,0.00", format: '₹0,0.00',
sign: "₹" sign: '₹'
}, },
ISK: { ISK: {
steps: ["LBCBTC", "BTCISK"], steps: ['LBCBTC', 'BTCISK'],
format: "kr 0,0.00", format: 'kr 0,0.00',
sign: "kr" sign: 'kr'
}, },
JPY: { JPY: {
steps: ["LBCBTC", "BTCJPY"], steps: ['LBCBTC', 'BTCJPY'],
format: "¥0,0.00", format: '¥0,0.00',
sign: "¥" sign: '¥'
}, },
KRW: { KRW: {
steps: ["LBCBTC", "BTCKRW"], steps: ['LBCBTC', 'BTCKRW'],
format: "₩0,0.00", format: '₩0,0.00',
sign: "₩" sign: '₩'
}, },
NZD: { NZD: {
steps: ["LBCBTC", "BTCNZD"], steps: ['LBCBTC', 'BTCNZD'],
format: "$0,0.00", format: '$0,0.00',
sign: "NZD " sign: 'NZD '
}, },
PLN: { PLN: {
steps: ["LBCBTC", "BTCPLN"], steps: ['LBCBTC', 'BTCPLN'],
format: "zł 0,0.00", format: 'zł 0,0.00',
sign: "zł" sign: 'zł'
}, },
RUB: { RUB: {
steps: ["LBCBTC", "BTCRUB"], steps: ['LBCBTC', 'BTCRUB'],
format: "RUB 0,0.00", format: 'RUB 0,0.00',
sign: "RUB" sign: 'RUB'
}, },
SEK: { SEK: {
steps: ["LBCBTC", "BTCSEK"], steps: ['LBCBTC', 'BTCSEK'],
format: "kr 0,0.00", format: 'kr 0,0.00',
sign: "kr" sign: 'kr'
}, },
SGD: { SGD: {
steps: ["LBCBTC", "BTCSGD"], steps: ['LBCBTC', 'BTCSGD'],
format: "$0,0.00", format: '$0,0.00',
sign: "SGD " sign: 'SGD '
}, },
THB: { THB: {
steps: ["LBCBTC", "BTCTHB"], steps: ['LBCBTC', 'BTCTHB'],
format: "฿0,0.00", format: '฿0,0.00',
sign: "฿" sign: '฿'
}, },
TWD: { TWD: {
steps: ["LBCBTC", "BTCTWD"], steps: ['LBCBTC', 'BTCTWD'],
format: "NT$0,0.00", format: 'NT$0,0.00',
sign: "NT$" sign: 'NT$'
}, },
IDR: { IDR: {
steps: ["LBCBTC", "BTCIDR"], steps: ['LBCBTC', 'BTCIDR'],
format: "Rp0,0.00", format: 'Rp0,0.00',
sign: "Rp" sign: 'Rp'
}, },
BTC: { BTC: {
steps: ["LBCBTC"], steps: ['LBCBTC'],
format: "0,0[.][00000000] BTC", format: '0,0[.][00000000] BTC',
sign: "BTC" sign: 'BTC'
} }
}, },
// api steps // api steps
api: { api: {
LBCBTC: { LBCBTC: {
url: "https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC", url: 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC',
path: "$.result.Bid" path: '$.result.Bid'
}, },
BTCUSD: { BTCUSD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.USD.buy" path: '$.USD.buy'
}, },
BTCGBP: { BTCGBP: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.GBP.buy" path: '$.GBP.buy'
}, },
BTCAUD: { BTCAUD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.AUD.buy" path: '$.AUD.buy'
}, },
BTCBRL: { BTCBRL: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.BRL.buy" path: '$.BRL.buy'
}, },
BTCCAD: { BTCCAD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.CAD.buy" path: '$.CAD.buy'
}, },
BTCCHF: { BTCCHF: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.CHF.buy" path: '$.CHF.buy'
}, },
BTCCLP: { BTCCLP: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.CLP.buy" path: '$.CLP.buy'
}, },
BTCCNY: { BTCCNY: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.CNY.buy" path: '$.CNY.buy'
}, },
BTCDKK: { BTCDKK: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.DKK.buy" path: '$.DKK.buy'
}, },
BTCEUR: { BTCEUR: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.EUR.buy" path: '$.EUR.buy'
}, },
BTCHKD: { BTCHKD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.HKD.buy" path: '$.HKD.buy'
}, },
BTCINR: { BTCINR: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.INR.buy" path: '$.INR.buy'
}, },
BTCISK: { BTCISK: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.ISK.buy" path: '$.ISK.buy'
}, },
BTCJPY: { BTCJPY: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.JPY.buy" path: '$.JPY.buy'
}, },
BTCKRW: { BTCKRW: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.KRW.buy" path: '$.KRW.buy'
}, },
BTCNZD: { BTCNZD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.NZD.buy" path: '$.NZD.buy'
}, },
BTCPLN: { BTCPLN: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.PLN.buy" path: '$.PLN.buy'
}, },
BTCRUB: { BTCRUB: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.RUB.buy" path: '$.RUB.buy'
}, },
BTCSEK: { BTCSEK: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.SEK.buy" path: '$.SEK.buy'
}, },
BTCSGD: { BTCSGD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.SGD.buy" path: '$.SGD.buy'
}, },
BTCTHB: { BTCTHB: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.THB.buy" path: '$.THB.buy'
}, },
BTCTWD: { BTCTWD: {
url: "https://blockchain.info/ticker", url: 'https://blockchain.info/ticker',
path: "$.TWD.buy" path: '$.TWD.buy'
}, },
BTCIDR: { BTCIDR: {
url: url: 'https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=IDR',
"https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=IDR", path: '$.IDR'
path: "$.IDR"
} }
}, },
// display date/time format // display date/time format
dtFormat: "Do MMM YYYY h:mma [UTC]", dtFormat: 'Do MMM YYYY h:mma [UTC]',
// refresh rate in milliseconds to retrieve a new price (default to 10 minutes) // refresh rate in milliseconds to retrieve a new price (default to 10 minutes)
refreshTime: 100000 refreshTime: 100000
}; };
var words = suffix var words = suffix
.trim() .trim()
.split(" ") .split(' ')
.filter(function(n) { .filter(function(n) {
return n !== ""; return n !== '';
}); });
var currency = var currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency;
words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency;
var amount = words.length > 1 ? parseFloat(words[1], 10) : 1; var amount = words.length > 1 ? parseFloat(words[1], 10) : 1;
var showHelp = var showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1;
isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1;
// store the last retrieved rate // store the last retrieved rate
var cachedRates = {}; var cachedRates = {};
var command = "!price"; var command = '!price';
var currencies = Object.keys(options.currencies); var currencies = Object.keys(options.currencies);
for (var i = 0; i < currencies.length; i++) { for (var i = 0; i < currencies.length; i++) {
@ -275,9 +272,7 @@ exports.price = {
doHelp(bot, msg, suffix); doHelp(bot, msg, suffix);
} else { } else {
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) { if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send( msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
"Please use <#" + ChannelID + "> or DMs to talk to price bot."
);
return; return;
} }
doSteps(bot, currency, amount); doSteps(bot, currency, amount);
@ -285,44 +280,32 @@ exports.price = {
function doHelp(bot, msg, suffix) { function doHelp(bot, msg, suffix) {
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) { if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send( msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
"Please use <#" + ChannelID + "> or DMs to talk to price bot."
);
return; return;
} }
var message = var message =
"**" + '**' +
command + command +
"**: show the price of 1 LBC in " + '**: show the price of 1 LBC in ' +
options.defaultCurrency + options.defaultCurrency +
"\n" + '\n' +
"**" + '**' +
command + command +
" help**: this message\n" + ' help**: this message\n' +
"**" + '**' +
command + command +
" CURRENCY**: show the price of 1 LBC in CURRENCY. Supported values for CURRENCY are Listed Below\n" + ' CURRENCY**: show the price of 1 LBC in CURRENCY. Supported values for CURRENCY are Listed Below\n' +
"**" + '**' +
command + command +
" CURRENCY AMOUNT**: show the price of AMOUNT LBC in CURRENCY\n" + ' CURRENCY AMOUNT**: show the price of AMOUNT LBC in CURRENCY\n' +
"**Supported Currencies:** *usd*, *gbp*, *eur*, *aud*, *brl*, *cad*, *chf*, *clp*, *cny*, *dkk*, *hkd*, *inr*, *isk*, *jpy*, *krw*, *nzd*, *pln* ,*rub*, *sek*, *sgd*, *thb*, *twd*, *idr* and *btc* (case-insensitive)"; '**Supported Currencies:** *usd*, *gbp*, *eur*, *aud*, *brl*, *cad*, *chf*, *clp*, *cny*, *dkk*, *hkd*, *inr*, *isk*, *jpy*, *krw*, *nzd*, *pln* ,*rub*, *sek*, *sgd*, *thb*, *twd*, *idr* and *btc* (case-insensitive)';
msg.channel.send(message); msg.channel.send(message);
} }
function formatMessage(amount, rate, option) { function formatMessage(amount, rate, option) {
var cur = option.sign; var cur = option.sign;
var value = numeral(rate.rate * amount).format(option.format); var value = numeral(rate.rate * amount).format(option.format);
return ( return '*' + numeral(amount).format('0,0[.][00000000]') + ' LBC = ' + cur + ' ' + value + '*\n_last updated ' + rate.time.utc().format(options.dtFormat) + '_';
"*" +
numeral(amount).format("0,0[.][00000000]") +
" LBC = " +
cur +
" " +
value +
"*\n_last updated " +
rate.time.utc().format(options.dtFormat) +
"_"
);
} }
function doSteps(bot, currency, amount) { function doSteps(bot, currency, amount) {
@ -330,9 +313,7 @@ exports.price = {
var shouldReload = true; var shouldReload = true;
if (cachedRates[currency]) { if (cachedRates[currency]) {
var cache = cachedRates[currency]; var cache = cachedRates[currency];
shouldReload = shouldReload = cache.time === null || moment().diff(cache.time) >= options.refreshTime;
cache.time === null ||
moment().diff(cache.time) >= options.refreshTime;
if (!shouldReload) { if (!shouldReload) {
var message = formatMessage(amount, cache, option); var message = formatMessage(amount, cache, option);
msg.channel.send(message); msg.channel.send(message);
@ -354,22 +335,14 @@ exports.price = {
if (steps.length > 0) { if (steps.length > 0) {
var pairName = steps[0]; var pairName = steps[0];
if (!options.api[pairName]) { if (!options.api[pairName]) {
msg.channel.send( msg.channel.send('There was a configuration error. ' + pairName + ' pair was not found.');
"There was a configuration error. " +
pairName +
" pair was not found."
);
return; return;
} }
var pair = options.api[pairName]; var pair = options.api[pairName];
request.get(pair.url, function(error, response, body) { request.get(pair.url, function(error, response, body) {
if (error) { if (error) {
msg.channel.send( msg.channel.send(err.message ? err.message : 'The request could not be completed at this time. Please try again later.');
err.message
? err.message
: "The request could not be completed at this time. Please try again later."
);
return; return;
} }
var pairRate = 0; var pairRate = 0;
@ -398,9 +371,7 @@ exports.price = {
cachedRates[currency] = result; cachedRates[currency] = result;
msg.channel.send(formatMessage(amount, result, option)); msg.channel.send(formatMessage(amount, result, option));
} else { } else {
msg.channel.send( msg.channel.send('The rate returned for the ' + pairName + ' pair was invalid.');
"The rate returned for the " + pairName + " pair was invalid."
);
} }
}); });
} }

View file

@ -1,13 +1,13 @@
let hasPerms = require("../helpers.js").hasPerms; let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
exports.commands = [ exports.commands = [
"purge" // command that is in this file, every command needs it own export as shown below 'purge' // command that is in this file, every command needs it own export as shown below
]; ];
exports.purge = { exports.purge = {
usage: "<number of messages>", usage: '<number of messages>',
description: "Deletes Messages", description: 'Deletes Messages',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
if (inPrivate(msg)) { if (inPrivate(msg)) {
msg.channel.send("You Cant Purge Message In DM's!"); msg.channel.send("You Cant Purge Message In DM's!");
@ -15,7 +15,7 @@ exports.purge = {
} }
if (hasPerms(msg)) { if (hasPerms(msg)) {
if (!suffix) { if (!suffix) {
var newamount = "2"; var newamount = '2';
} else { } else {
var amount = Number(suffix); var amount = Number(suffix);
var adding = 1; var adding = 1;
@ -29,25 +29,15 @@ exports.purge = {
.then(messages => { .then(messages => {
msg.channel.bulkDelete(messages); msg.channel.bulkDelete(messages);
// Logging the number of messages deleted on both the channel and console. // Logging the number of messages deleted on both the channel and console.
msg.channel msg.channel.send('Deletion of messages successful. \n Total messages deleted including command: ' + newamount).then(message => message.delete(5000));
.send( console.log('Deletion of messages successful. \n Total messages deleted including command: ' + newamount);
"Deletion of messages successful. \n Total messages deleted including command: " +
newamount
)
.then(message => message.delete(5000));
console.log(
"Deletion of messages successful. \n Total messages deleted including command: " +
newamount
);
}) })
.catch(err => { .catch(err => {
console.log("Error while doing Bulk Delete"); console.log('Error while doing Bulk Delete');
console.log(err); console.log(err);
}); });
} else { } else {
msg.channel msg.channel.send('only moderators can use this command!').then(message => message.delete(5000));
.send("only moderators can use this command!")
.then(message => message.delete(5000));
} }
} }
}; };

View file

@ -1,25 +1,25 @@
let request = require("request"); let request = require('request');
let config = require("config"); let config = require('config');
let hasPerms = require("../helpers.js").hasPerms; let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get("gitrelease").channel; let ChannelID = config.get('gitrelease').channel;
exports.commands = [ exports.commands = [
"releasenotes" // command that is in this file, every command needs it own export as shown below 'releasenotes' // command that is in this file, every command needs it own export as shown below
]; ];
exports.releasenotes = { exports.releasenotes = {
usage: "", usage: '',
description: "gets current release notes from GITHUB", description: 'gets current release notes from GITHUB',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
var headers = { var headers = {
"Content-Type": "application/json", 'Content-Type': 'application/json',
"User-Agent": "Super Agent/0.0.1" 'User-Agent': 'Super Agent/0.0.1'
}; };
// Configure the request // Configure the request
var options = { var options = {
url: "https://api.github.com/repos/lbryio/lbry-app/releases/latest", url: 'https://api.github.com/repos/lbryio/lbry-app/releases/latest',
method: "GET", method: 'GET',
headers: headers headers: headers
}; };
@ -32,19 +32,18 @@ exports.releasenotes = {
if (releasemessage.length < 2000) { if (releasemessage.length < 2000) {
message = { message = {
embed: { embed: {
title: "*Download " + releasename + " here!*", title: '*Download ' + releasename + ' here!*',
description: releasemessage, description: releasemessage,
url: releaseurl, url: releaseurl,
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
name: "Lbry-app Release Notes for " + releasename, name: 'Lbry-app Release Notes for ' + releasename,
icon_url: icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
}, },
footer: { footer: {
icon_url: "https://i.imgur.com/yWf5USu.png", icon_url: 'https://i.imgur.com/yWf5USu.png',
text: "Lbry-app Updated " text: 'Lbry-app Updated '
} }
} }
}; };
@ -52,18 +51,18 @@ exports.releasenotes = {
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
if (hasPerms(msg) && suffix === "post") { if (hasPerms(msg) && suffix === 'post') {
bot.channels.get(ChannelID).send(message); bot.channels.get(ChannelID).send(message);
} else { } else {
msg.channel.send(msg.author + " Release notes sent via DM"); msg.channel.send(msg.author + ' Release notes sent via DM');
msg.author.send(message); msg.author.send(message);
} }
} else { } else {
message = releasemessage message = releasemessage
.trim() .trim()
.split("###") .split('###')
.filter(function(n) { .filter(function(n) {
return n !== ""; return n !== '';
}); });
releasemessage1 = message[0]; releasemessage1 = message[0];
releasemessage2 = message[1]; releasemessage2 = message[1];
@ -72,19 +71,18 @@ exports.releasenotes = {
releasemessage5 = message[4]; releasemessage5 = message[4];
message1 = { message1 = {
embed: { embed: {
title: "*Download " + releasename + " here!*", title: '*Download ' + releasename + ' here!*',
description: releasemessage1, description: releasemessage1,
url: releaseurl, url: releaseurl,
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
name: "Lbry-app Release Notes for " + releasename, name: 'Lbry-app Release Notes for ' + releasename,
icon_url: icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
}, },
footer: { footer: {
icon_url: "https://i.imgur.com/yWf5USu.png", icon_url: 'https://i.imgur.com/yWf5USu.png',
text: "Lbry-app Updated " text: 'Lbry-app Updated '
} }
} }
}; };
@ -94,12 +92,11 @@ exports.releasenotes = {
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
icon_url: icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
}, },
footer: { footer: {
icon_url: "https://i.imgur.com/yWf5USu.png", icon_url: 'https://i.imgur.com/yWf5USu.png',
text: "Lbry-app Updated " text: 'Lbry-app Updated '
} }
} }
}; };
@ -109,12 +106,11 @@ exports.releasenotes = {
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
icon_url: icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
}, },
footer: { footer: {
icon_url: "https://i.imgur.com/yWf5USu.png", icon_url: 'https://i.imgur.com/yWf5USu.png',
text: "Lbry-app Updated " text: 'Lbry-app Updated '
} }
} }
}; };
@ -124,12 +120,11 @@ exports.releasenotes = {
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
icon_url: icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
}, },
footer: { footer: {
icon_url: "https://i.imgur.com/yWf5USu.png", icon_url: 'https://i.imgur.com/yWf5USu.png',
text: "Lbry-app Updated " text: 'Lbry-app Updated '
} }
} }
}; };
@ -139,12 +134,11 @@ exports.releasenotes = {
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
icon_url: icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
}, },
footer: { footer: {
icon_url: "https://i.imgur.com/yWf5USu.png", icon_url: 'https://i.imgur.com/yWf5USu.png',
text: "Lbry-app Updated " text: 'Lbry-app Updated '
} }
} }
}; };
@ -156,14 +150,14 @@ exports.releasenotes = {
msg.channel.send(message5); msg.channel.send(message5);
return; return;
} }
if (hasPerms(msg) && suffix === "post") { if (hasPerms(msg) && suffix === 'post') {
bot.channels.get(ChannelID).send(message1); bot.channels.get(ChannelID).send(message1);
bot.channels.get(ChannelID).send(message2); bot.channels.get(ChannelID).send(message2);
bot.channels.get(ChannelID).send(message3); bot.channels.get(ChannelID).send(message3);
bot.channels.get(ChannelID).send(message4); bot.channels.get(ChannelID).send(message4);
bot.channels.get(ChannelID).send(message5); bot.channels.get(ChannelID).send(message5);
} else { } else {
msg.channel.send(msg.author + " Release notes sent via DM"); msg.channel.send(msg.author + ' Release notes sent via DM');
msg.author.send(message1); msg.author.send(message1);
msg.author.send(message2); msg.author.send(message2);
msg.author.send(message3); msg.author.send(message3);

View file

@ -1,19 +1,19 @@
let config = require("config"); let config = require('config');
let botconfig = config.get("bot"); let botconfig = config.get('bot');
let rolelist = config.get("rolelist"); let rolelist = config.get('rolelist');
exports.commands = [ exports.commands = [
"addrole", // command that is in this file, every command needs it own export as shown below 'addrole', // command that is in this file, every command needs it own export as shown below
"delrole", 'delrole',
"roles" 'roles'
]; ];
exports.addrole = { exports.addrole = {
usage: "<role>", usage: '<role>',
description: "Adds you to specified role", description: 'Adds you to specified role',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
// Here the bot,msg and suffix is avaible, this function can be async if needed. // Here the bot,msg and suffix is avaible, this function can be async if needed.
var newrole = msg.guild.roles.find("name", suffix); var newrole = msg.guild.roles.find('name', suffix);
// Checks if the user put a role in the message. // Checks if the user put a role in the message.
if (suffix) { if (suffix) {
@ -22,48 +22,28 @@ exports.addrole = {
// Checks if the role even exists in the discord server // Checks if the role even exists in the discord server
if (newrole !== null) { if (newrole !== null) {
// Checks if the member has the role that they are trying to add // Checks if the member has the role that they are trying to add
if (!msg.member.roles.find("name", suffix)) { if (!msg.member.roles.find('name', suffix)) {
msg.member msg.member.addRole(newrole).then(msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!'));
.addRole(newrole)
.then(
msg.channel.send(
msg.member + " has been added to the " + suffix + " role!"
)
);
} else { } else {
msg.channel.send( msg.channel.send('It seems that you already have that role! Try removing it first with the ' + botconfig.prefix + 'delrole command!');
"It seems that you already have that role! Try removing it first with the " +
botconfig.prefix +
"delrole command!"
);
} }
} else { } else {
msg.channel.send( msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!');
"The role " + "`" + suffix + "`" + " does not exist!"
);
} }
} else { } else {
msg.channel.send( 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.');
"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 { } else {
msg.channel.send( msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
"Please specify a role. Type " +
botconfig.prefix +
"roles to see which you may add!"
);
} }
} }
}; };
exports.delrole = { exports.delrole = {
usage: "<role>", usage: '<role>',
description: "Deletes your role specified", description: 'Deletes your role specified',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
// Here the bot,msg and suffix is avaible, this function can be async if needed. // Here the bot,msg and suffix is avaible, this function can be async if needed.
let oldrole = msg.guild.roles.find("name", suffix); let oldrole = msg.guild.roles.find('name', suffix);
// Checks if the user put a role in the message. // Checks if the user put a role in the message.
if (suffix) { if (suffix) {
// Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config. // Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config.
@ -71,62 +51,42 @@ exports.delrole = {
// Checks if the role even exists in the discord server // Checks if the role even exists in the discord server
if (oldrole !== null) { if (oldrole !== null) {
// Checks if the member has the role that they are trying to add // Checks if the member has the role that they are trying to add
if (msg.member.roles.find("name", suffix)) { if (msg.member.roles.find('name', suffix)) {
msg.member msg.member.removeRole(oldrole).then(msg.channel.send(msg.member + ' has been removed from the ' + suffix + ' role!'));
.removeRole(oldrole)
.then(
msg.channel.send(
msg.member + " has been removed from the " + suffix + " role!"
)
);
} else { } else {
msg.channel.send( msg.channel.send("You don't seem to have that role! Try adding it first with the " + botconfig.prefix + 'addrole command!');
"You don't seem to have that role! Try adding it first with the " +
botconfig.prefix +
"addrole command!"
);
} }
} else { } else {
msg.channel.send( msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!');
"The role " + "`" + suffix + "`" + " does not exist!"
);
} }
} else { } else {
msg.channel.send( 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.');
"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 { } else {
msg.channel.send( msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
"Please specify a role. Type " +
botconfig.prefix +
"roles to see which you may add!"
);
} }
} }
}; };
exports.roles = { exports.roles = {
usage: "", usage: '',
description: "displays roles you can give yourself", description: 'displays roles you can give yourself',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
// Here the bot,msg and suffix is avaible, this function can be async if needed. // Here the bot,msg and suffix is avaible, this function can be async if needed.
msg.channel.send({ msg.channel.send({
embed: { embed: {
color: 3447003, color: 3447003,
title: "Wunderbot", title: 'Wunderbot',
description: "You have accessed the rolebot function of Wunderbot!", description: 'You have accessed the rolebot function of Wunderbot!',
fields: [ fields: [
{ {
name: "List of roles", name: 'List of roles',
value: buildRoleString(rolelist.allowedroles), value: buildRoleString(rolelist.allowedroles),
inline: false inline: false
} }
], ],
footer: { footer: {
icon_url: msg.author.avatarURL, icon_url: msg.author.avatarURL,
text: "Requested by: " + JSON.stringify(msg.author.username) text: 'Requested by: ' + JSON.stringify(msg.author.username)
} }
} }
}); });
@ -135,9 +95,9 @@ exports.roles = {
}; };
function buildRoleString(roles) { function buildRoleString(roles) {
let str = ""; let str = '';
for (let i = 0; i < roles.length; i++) { for (let i = 0; i < roles.length; i++) {
str += "`" + roles[i] + "`" + "\n"; str += '`' + roles[i] + '`' + '\n';
} }
return str; return str;
} }

View file

@ -2,12 +2,12 @@ const authors = [];
let warned = []; let warned = [];
let banned = []; let banned = [];
let messagelog = []; let messagelog = [];
let config = require("config"); let config = require('config');
let botlog = config.get("moderation").logchannel; let botlog = config.get('moderation').logchannel;
let hasPerms = require("../helpers.js").hasPerms; let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let hasExcludedSpamChannels = require("../helpers.js").hasExcludedSpamChannels; let hasExcludedSpamChannels = require('../helpers.js').hasExcludedSpamChannels;
let hasExcludedSpamUsers = require("../helpers.js").hasExcludedSpamUsers; let hasExcludedSpamUsers = require('../helpers.js').hasExcludedSpamUsers;
/** /**
* Add simple spam protection to your discord server. * Add simple spam protection to your discord server.
@ -16,26 +16,19 @@ let hasExcludedSpamUsers = require("../helpers.js").hasExcludedSpamUsers;
* @return {[type]} [description] * @return {[type]} [description]
*/ */
exports.custom = ["antiSpam"]; exports.custom = ['antiSpam'];
exports.antiSpam = function(bot) { exports.antiSpam = function(bot) {
const warnBuffer = 5; const warnBuffer = 5;
const maxBuffer = 10; const maxBuffer = 10;
const interval = 1500; const interval = 1500;
const warningMessage = const warningMessage = ', Stop spamming or you will be banned! This is your warning!';
", Stop spamming or you will be banned! This is your warning!"; const banMessage = 'has been banned for spamming!';
const banMessage = "has been banned for spamming!";
const maxDuplicatesWarning = 5; const maxDuplicatesWarning = 5;
const maxDuplicatesBan = 10; const maxDuplicatesBan = 10;
bot.on("message", msg => { bot.on('message', msg => {
if ( if (inPrivate(msg) || msg.author.bot || hasPerms(msg) || hasExcludedSpamChannels(msg) || hasExcludedSpamUsers(msg)) {
inPrivate(msg) ||
msg.author.bot ||
hasPerms(msg) ||
hasExcludedSpamChannels(msg) ||
hasExcludedSpamUsers(msg)
) {
return; return;
} }
if (msg.author.id != bot.user.id) { if (msg.author.id != bot.user.id) {
@ -52,11 +45,7 @@ exports.antiSpam = function(bot) {
// Check how many times the same message has been sent. // Check how many times the same message has been sent.
let msgMatch = 0; let msgMatch = 0;
for (let i = 0; i < messagelog.length; i++) { for (let i = 0; i < messagelog.length; i++) {
if ( if (messagelog[i].message == msg.content && messagelog[i].author == msg.author.id && msg.author.id !== bot.user.id) {
messagelog[i].message == msg.content &&
messagelog[i].author == msg.author.id &&
msg.author.id !== bot.user.id
) {
msgMatch++; msgMatch++;
} }
} }
@ -99,7 +88,7 @@ exports.antiSpam = function(bot) {
*/ */
function warn(msg, userid) { function warn(msg, userid) {
warned.push(msg.author.id); warned.push(msg.author.id);
msg.channel.send(msg.author + " " + warningMessage); msg.channel.send(msg.author + ' ' + warningMessage);
} }
/** /**
@ -117,21 +106,17 @@ exports.antiSpam = function(bot) {
banned.push(msg.author.id); banned.push(msg.author.id);
let user = msg.channel.guild.members.find( let user = msg.channel.guild.members.find(member => member.user.id === msg.author.id);
member => member.user.id === msg.author.id
);
if (user) { if (user) {
user user
.ban() .ban()
.then(member => { .then(member => {
msg.channel.send(msg.author + " " + banMessage); msg.channel.send(msg.author + ' ' + banMessage);
bot.channels.get(botlog).send(msg.author + " " + banMessage); bot.channels.get(botlog).send(msg.author + ' ' + banMessage);
return true; return true;
}) })
.catch(() => { .catch(() => {
msg.channel.send( msg.channel.send('insufficient permission to kick ' + msg.author + ' for spamming.');
"insufficient permission to kick " + msg.author + " for spamming."
);
return false; return false;
}); });
} }

View file

@ -1,56 +1,54 @@
let request = require("request"); let request = require('request');
let wget = require("wget"); let wget = require('wget');
let fs = require("fs"); let fs = require('fs');
let config = require("config"); let config = require('config');
let hasSpeechBotChannels = require("../helpers.js").hasSpeechBotChannels; let hasSpeechBotChannels = require('../helpers.js').hasSpeechBotChannels;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get("speechbot").mainchannel; let ChannelID = config.get('speechbot').mainchannel;
//debug output "true/false" outputs same error as slack message in console if set to true //debug output "true/false" outputs same error as slack message in console if set to true
//if set to false console will be left blank like normal //if set to false console will be left blank like normal
//some have more info on file details of error //some have more info on file details of error
let FullDebug = "true"; let FullDebug = 'true';
//outputs response from speech, very bulk reply //outputs response from speech, very bulk reply
let ResponseDebug = "false"; let ResponseDebug = 'false';
exports.commands = [ exports.commands = [
"speech" // command that is in this file, every command needs it own export as shown below 'speech' // command that is in this file, every command needs it own export as shown below
]; ];
exports.speech = { exports.speech = {
usage: "<name>", usage: '<name>',
description: "gets top claim from spee.ch, coming soon post to spee.ch", description: 'gets top claim from spee.ch, coming soon post to spee.ch',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
if (!hasSpeechBotChannels(msg) && !inPrivate(msg)) { if (!hasSpeechBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send( msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to speech bot.');
"Please use <#" + ChannelID + "> or DMs to talk to speech bot."
);
return; return;
} }
var command = "!speech"; var command = '!speech';
words = suffix words = suffix
.trim() .trim()
.split(" ") .split(' ')
.filter(function(n) { .filter(function(n) {
return n !== ""; return n !== '';
}); });
var imagename = words[0]; var imagename = words[0];
//check if image name is help, if it is then do help message //check if image name is help, if it is then do help message
if (imagename == "help") { if (imagename == 'help') {
doHelp(bot, msg, suffix); doHelp(bot, msg, suffix);
return; return;
} else { } else {
//check if imagename is defined if not do error //check if imagename is defined if not do error
if (imagename === undefined) { if (imagename === undefined) {
if (FullDebug === "true") { if (FullDebug === 'true') {
var message = "`no name provided`"; var message = '`no name provided`';
console.log("no name provided"); console.log('no name provided');
msg.channel.send(message); msg.channel.send(message);
doHelp(bot, msg, suffix); doHelp(bot, msg, suffix);
return; return;
} else { } else {
var message = "`no name provided`"; var message = '`no name provided`';
msg.channel.send(message); msg.channel.send(message);
doHelp(bot, msg, suffix); doHelp(bot, msg, suffix);
return; return;
@ -62,19 +60,13 @@ exports.speech = {
//check if a url is provided if none do help message //check if a url is provided if none do help message
if (filepath === undefined) { if (filepath === undefined) {
if (FullDebug === "true") { if (FullDebug === 'true') {
var message = var message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
"`no url provided, fetching image from:`\n" + console.log('no url provided');
"https://spee.ch/" +
imagename;
console.log("no url provided");
msg.channel.send(message); msg.channel.send(message);
return; return;
} else { } else {
var message = var message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
"`no url provided, fetching image from:`\n" +
"https://spee.ch/" +
imagename;
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
@ -87,16 +79,14 @@ exports.speech = {
var linkvalid = url.slice(0, 4); var linkvalid = url.slice(0, 4);
//check of url provided begins with http in not throw error and help message //check of url provided begins with http in not throw error and help message
if (linkvalid !== "http") { if (linkvalid !== 'http') {
if (FullDebug === "true") { if (FullDebug === 'true') {
var message = var message = '`error not a valid url, please start with http or https`';
"`error not a valid url, please start with http or https`"; console.log('invalid url provided: ' + filepath);
console.log("invalid url provided: " + filepath);
msg.channel.send(message); msg.channel.send(message);
return; return;
} else { } else {
var message = var message = '`error not a valid url, please start with http or https`';
"`error not a valid url, please start with http or https`";
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
@ -105,13 +95,13 @@ exports.speech = {
//function to check if url is an image //function to check if url is an image
var isUriImage = function(uri) { var isUriImage = function(uri) {
//make sure we remove any nasty GET params //make sure we remove any nasty GET params
uri = uri.split("?")[0]; uri = uri.split('?')[0];
//moving on, split the uri into parts that had dots before them //moving on, split the uri into parts that had dots before them
var parts = uri.split("."); var parts = uri.split('.');
//get the last part ( should be the extension ) //get the last part ( should be the extension )
var extension = parts[parts.length - 1]; var extension = parts[parts.length - 1];
//define some image types to test against //define some image types to test against
var imageTypes = ["jpg", "jpeg", "tiff", "png", "gif", "bmp"]; var imageTypes = ['jpg', 'jpeg', 'tiff', 'png', 'gif', 'bmp'];
//check if the extension matches anything in the list. if it does set true if not set false //check if the extension matches anything in the list. if it does set true if not set false
if (imageTypes.indexOf(extension) !== -1) { if (imageTypes.indexOf(extension) !== -1) {
return true; return true;
@ -122,15 +112,13 @@ exports.speech = {
//check if url is an image if its not throw error and help message //check if url is an image if its not throw error and help message
if (isUriImage(url) === false) { if (isUriImage(url) === false) {
if (FullDebug === "true") { if (FullDebug === 'true') {
var message = var message = '`error not a valid image url, be sure the link includes a file type`';
"`error not a valid image url, be sure the link includes a file type`"; console.log('invalid url provided: ' + url);
console.log("invalid url provided: " + url);
msg.channel.send(message); msg.channel.send(message);
return; return;
} else { } else {
var message = var message = '`error not a valid image url, be sure the link includes a file type`';
"`error not a valid image url, be sure the link includes a file type`";
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
@ -139,49 +127,40 @@ exports.speech = {
var eighteen = words[2]; var eighteen = words[2];
//check is NSFW if yes or no sets proper value if none //check is NSFW if yes or no sets proper value if none
if ( if (eighteen == '' || eighteen == 'none' || eighteen == undefined || eighteen == null || eighteen == 'no' || eighteen == 'false' || eighteen == false || eighteen == 'n') {
eighteen == "" || eighteen = 'no';
eighteen == "none" ||
eighteen == undefined ||
eighteen == null ||
eighteen == "no" ||
eighteen == "false" ||
eighteen == false ||
eighteen == "n"
) {
eighteen = "no";
} else { } else {
eighteen = "yes"; eighteen = 'yes';
} }
//prepare url for wget //prepare url for wget
var source = url; var source = url;
//parse the filename to use to save file //parse the filename to use to save file
filepath = source.split("/").pop(); filepath = source.split('/').pop();
//set proper directory for downloading image //set proper directory for downloading image
var outputFile = "speech-uploads/" + filepath; var outputFile = 'speech-uploads/' + filepath;
//set download directory to current working directory //set download directory to current working directory
var dir = process.cwd(); var dir = process.cwd();
//set full path to directory for speech uploading //set full path to directory for speech uploading
var fullpath = dir + "\\speech-uploads\\" + filepath; var fullpath = dir + '\\speech-uploads\\' + filepath;
//download url via wget //download url via wget
var download = wget.download(url, outputFile); var download = wget.download(url, outputFile);
//check if url is reachable if not throw error //check if url is reachable if not throw error
download.on("error", function(err) { download.on('error', function(err) {
if (FullDebug === "true") { if (FullDebug === 'true') {
console.log("error could not reach: " + url + " : " + err); console.log('error could not reach: ' + url + ' : ' + err);
var message = "`error url could not be reached`"; var message = '`error url could not be reached`';
msg.channel.send(message); msg.channel.send(message);
return; return;
} else { } else {
var message = "`error url could not be reached`"; var message = '`error url could not be reached`';
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
}); });
download.on("end", output => { download.on('end', output => {
//if no errors and file ready -> do the request //if no errors and file ready -> do the request
output && doSteps(bot, imagename, url, eighteen); output && doSteps(bot, imagename, url, eighteen);
}); });
@ -191,17 +170,17 @@ exports.speech = {
function doHelp(bot, msg, suffix) { function doHelp(bot, msg, suffix) {
msg.channel.send({ msg.channel.send({
embed: { embed: {
title: "", title: '',
description: description:
"**!speech `<Name>`** : *displays top claim on speech* \n\n\n" + '**!speech `<Name>`** : *displays top claim on speech* \n\n\n' +
"**COMING SOON POSTING TO SPEECH** \n\n" + '**COMING SOON POSTING TO SPEECH** \n\n' +
"**!speech `<Name> <URL> <NSFW>`** : *Uploads Image URL to Spee.ch* \n" + '**!speech `<Name> <URL> <NSFW>`** : *Uploads Image URL to Spee.ch* \n' +
"**NOTE : dont include spaces in name (NSFW is optional true/false, if left blank will default to false)** \n" + '**NOTE : dont include spaces in name (NSFW is optional true/false, if left blank will default to false)** \n' +
"EXAMPLE : `!speech my-image-name https://url/to/image.png false`", 'EXAMPLE : `!speech my-image-name https://url/to/image.png false`',
color: 7976557, color: 7976557,
author: { author: {
name: "Speech Bot Help", name: 'Speech Bot Help',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
@ -211,7 +190,7 @@ exports.speech = {
function doSteps(bot, imagename, url, eighteen) { function doSteps(bot, imagename, url, eighteen) {
request.post( request.post(
//url to send post request //url to send post request
"https://spee.ch/api/publish", 'https://spee.ch/api/publish',
//json payload //json payload
{ {
json: { json: {
@ -223,7 +202,7 @@ exports.speech = {
//get response from server //get response from server
function(error, response, body) { function(error, response, body) {
//output response if ResponseDebug set to true //output response if ResponseDebug set to true
if (ResponseDebug === "true") { if (ResponseDebug === 'true') {
console.log(response); console.log(response);
console.log(error); console.log(error);
console.log(body.success); console.log(body.success);
@ -231,59 +210,36 @@ exports.speech = {
} }
//check speech response for file path error, if found throw internal error! //check speech response for file path error, if found throw internal error!
if (body.message === "no files found in request") { if (body.message === 'no files found in request') {
if (FullDebug === "true") { if (FullDebug === 'true') {
console.log("no file found: " + fullpath); console.log('no file found: ' + fullpath);
var message = var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
msg.channel.send(message); msg.channel.send(message);
return; return;
} else { } else {
var message = var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
} }
//check speech response for filename error, if found throw internal error! //check speech response for filename error, if found throw internal error!
if (body.message === "no name field found in request") { if (body.message === 'no name field found in request') {
if (FullDebug === "true") { if (FullDebug === 'true') {
console.log("no name field found: " + imagename); console.log('no name field found: ' + imagename);
var message = var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
msg.channel.send(message); msg.channel.send(message);
return; return;
} else { } else {
var message = var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
msg.channel.send(message); msg.channel.send(message);
return; return;
} }
} }
//if no errors post this message //if no errors post this message
var message = var message = 'uploading... \n "name":"' + imagename + '",\n "URL": "' + url + '",\n "nsfw":"' + eighteen + '"\n to spee.ch';
'uploading... \n "name":"' + console.log('uploading... \n "name":"' + imagename + '",\n "file name": "' + filepath + '",\n "url":"' + url + '"\n "path":"' + fullpath + '"\n "nsfw": "' + eighteen + '"');
imagename +
'",\n "URL": "' +
url +
'",\n "nsfw":"' +
eighteen +
'"\n to spee.ch';
console.log(
'uploading... \n "name":"' +
imagename +
'",\n "file name": "' +
filepath +
'",\n "url":"' +
url +
'"\n "path":"' +
fullpath +
'"\n "nsfw": "' +
eighteen +
'"'
);
msg.channel.send(message); msg.channel.send(message);
} }
); );

View file

@ -1,152 +1,143 @@
let jp = require("jsonpath"); let jp = require('jsonpath');
let moment = require("moment"); let moment = require('moment');
let numeral = require("numeral"); let numeral = require('numeral');
let request = require("request"); let request = require('request');
let config = require("config"); let config = require('config');
let needle = require("needle"); let needle = require('needle');
let hasStatsBotChannels = require("../helpers.js").hasStatsBotChannels; let hasStatsBotChannels = require('../helpers.js').hasStatsBotChannels;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get("statsbot").mainchannel; let ChannelID = config.get('statsbot').mainchannel;
let statsurl = "https://coinmarketcap.com/currencies/library-credit/"; let statsurl = 'https://coinmarketcap.com/currencies/library-credit/';
exports.commands = [ 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 = { 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( needle.get('https://api.coinmarketcap.com/v1/ticker/library-credit/', function(error, response) {
"https://api.coinmarketcap.com/v1/ticker/library-credit/", if (error || response.statusCode !== 200) {
function(error, response) { msg.channel.send('coinmarketcap API is not available');
if (error || response.statusCode !== 200) { } else {
msg.channel.send("coinmarketcap API is not available"); var data = response.body[0];
} else { var rank = data.rank;
var data = response.body[0]; var price_usd = Number(data.price_usd);
var rank = data.rank; var price_btc = Number(data.price_btc);
var price_usd = Number(data.price_usd); var market_cap_usd = Number(data.market_cap_usd);
var price_btc = Number(data.price_btc); var available_supply = Number(data.available_supply);
var market_cap_usd = Number(data.market_cap_usd); var total_supply = Number(data.total_supply);
var available_supply = Number(data.available_supply); var percent_change_1h = Number(data.percent_change_1h);
var total_supply = Number(data.total_supply); var percent_change_24h = Number(data.percent_change_24h);
var percent_change_1h = Number(data.percent_change_1h); var json = response.body[0];
var percent_change_24h = Number(data.percent_change_24h); var newjson = parse_obj(json);
var json = response.body[0]; var parse = JSON.stringify(newjson);
var newjson = parse_obj(json); var volume24_usd = parse.replace(/[^0-9]/g, '');
var parse = JSON.stringify(newjson); var dt = new Date();
var volume24_usd = parse.replace(/[^0-9]/g, ""); var timestamp = dt.toUTCString();
var dt = new Date(); var hr_indicator = ':thumbsup:';
var timestamp = dt.toUTCString(); var day_indicator = ':thumbsup:';
var hr_indicator = ":thumbsup:"; if (percent_change_1h < 0) {
var day_indicator = ":thumbsup:"; hr_indicator = ':thumbsdown:';
if (percent_change_1h < 0) { }
hr_indicator = ":thumbsdown:"; if (percent_change_24h < 0) {
} day_indicator = ':thumbsdown:';
if (percent_change_24h < 0) { }
day_indicator = ":thumbsdown:";
}
needle.get( needle.get('https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=GBP', function(error, response) {
"https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=GBP", if (error || response.statusCode !== 200) {
function(error, response) { msg.channel.send('coinmarketcap API is not available');
} else {
var data = response.body[0];
var price_gbp = Number(data.price_gbp);
needle.get('https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=EUR', function(error, response) {
if (error || response.statusCode !== 200) { if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available"); msg.channel.send('coinmarketcap API is not available');
} else { } else {
var data = response.body[0]; var data = response.body[0];
var price_gbp = Number(data.price_gbp); var price_eur = Number(data.price_eur);
needle.get( description =
"https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=EUR", '**Rank: [' +
function(error, response) { rank +
if (error || response.statusCode !== 200) { '](' +
msg.channel.send("coinmarketcap API is not available"); statsurl +
} else { ')**\n' +
var data = response.body[0]; '**Data**\n' +
var price_eur = Number(data.price_eur); 'Market Cap: [$' +
description = numberWithCommas(market_cap_usd) +
"**Rank: [" + '](' +
rank + statsurl +
"](" + ') \n' +
statsurl + 'Total Supply: [' +
")**\n" + numberWithCommas(total_supply) +
"**Data**\n" + ' LBC](' +
"Market Cap: [$" + statsurl +
numberWithCommas(market_cap_usd) + ')\n' +
"](" + 'Circulating Supply: [' +
statsurl + numberWithCommas(available_supply) +
") \n" + ' LBC](' +
"Total Supply: [" + statsurl +
numberWithCommas(total_supply) + ')\n' +
" LBC](" + '24 Hour Volume: [$' +
statsurl + volume24_usd +
")\n" + '](' +
"Circulating Supply: [" + statsurl +
numberWithCommas(available_supply) + ') \n\n' +
" LBC](" + '**Price**\n' +
statsurl + 'BTC: [₿' +
")\n" + price_btc.toFixed(8) +
"24 Hour Volume: [$" + '](' +
volume24_usd + statsurl +
"](" + ')\n' +
statsurl + 'USD: [$' +
") \n\n" + price_usd.toFixed(2) +
"**Price**\n" + '](' +
"BTC: [₿" + statsurl +
price_btc.toFixed(8) + ') \n' +
"](" + 'EUR: [€' +
statsurl + price_eur.toFixed(2) +
")\n" + '](' +
"USD: [$" + statsurl +
price_usd.toFixed(2) + ') \n' +
"](" + 'GBP: [£' +
statsurl + price_gbp.toFixed(2) +
") \n" + '](' +
"EUR: [€" + statsurl +
price_eur.toFixed(2) + ') \n\n' +
"](" + '**% Change**\n' +
statsurl + '1 Hour: [' +
") \n" + percent_change_1h +
"GBP: [£" + '](' +
price_gbp.toFixed(2) + statsurl +
"](" + ') ' +
statsurl + hr_indicator +
") \n\n" + ' \n\n' +
"**% Change**\n" + '1 Day: [' +
"1 Hour: [" + percent_change_24h +
percent_change_1h + '](' +
"](" + statsurl +
statsurl + ') ' +
") " + day_indicator +
hr_indicator + ' \n\n';
" \n\n" + const embed = {
"1 Day: [" + description: description,
percent_change_24h + color: 7976557,
"](" + footer: {
statsurl + text: 'Last Updated: ' + timestamp
") " + },
day_indicator + author: {
" \n\n"; name: 'Coin Market Cap Stats (LBC)',
const embed = { url: statsurl,
description: description, icon_url: 'https://i.imgur.com/yWf5USu.png'
color: 7976557,
footer: {
text: "Last Updated: " + timestamp
},
author: {
name: "Coin Market Cap Stats (LBC)",
url: statsurl,
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({ embed });
}
} }
); };
msg.channel.send({ embed });
} }
} });
); }
} });
} }
); });
function parse_obj(obj) { function parse_obj(obj) {
var array = []; var array = [];
var prop; var prop;
@ -154,7 +145,7 @@ exports.stats = {
if (obj.hasOwnProperty(prop)) { if (obj.hasOwnProperty(prop)) {
var key = parseInt(prop, 10); var key = parseInt(prop, 10);
var value = obj[prop]; var value = obj[prop];
if (typeof value == "object") { if (typeof value == 'object') {
value = parse_obj(value); value = parse_obj(value);
} }
array[key] = value; array[key] = value;
@ -163,7 +154,7 @@ exports.stats = {
return array; return array;
} }
function numberWithCommas(x) { function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} }
} }
}; };

View file

@ -1,35 +1,35 @@
"use strict"; 'use strict';
//let config = require("config"); //let config = require("config");
//let rolelist = config.get("rolelist"); //let rolelist = config.get("rolelist");
const Discord = require("discord.js"); const Discord = require('discord.js');
let initialized = false; let initialized = false;
let discordBot = null; let discordBot = null;
module.exports = { module.exports = {
init: init init: init
}; };
function init(discordBot_) { function init(discordBot_) {
if (initialized) { if (initialized) {
throw new Error("init was already called once"); throw new Error('init was already called once');
} }
discordBot = discordBot_; discordBot = discordBot_;
discordBot.on("message", checkForCommand); discordBot.on('message', checkForCommand);
} }
/** /**
* *
* @param {String} message * @param {String} message
*/ */
let checkForCommand = function (message) { let checkForCommand = function(message) {
//if the close command is found //if the close command is found
if (!message.author.bot && message.content.toLowerCase().indexOf('!close') >= 0) { if (!message.author.bot && message.content.toLowerCase().indexOf('!close') >= 0) {
//send the -close command twice with a 4 seconds timeout //send the -close command twice with a 4 seconds timeout
message.channel.send("-close").catch(console.error); message.channel.send('-close').catch(console.error);
setTimeout(() => { setTimeout(() => {
message.channel.send("-close").catch(console.error); message.channel.send('-close').catch(console.error);
}, 4000); }, 4000);
} }
}; };

View file

@ -1,9 +1,8 @@
"use strict"; 'use strict';
exports.commands = ["tip"]; exports.commands = ['tip'];
exports.tip = { exports.tip = {
usage: "<subcommand>", usage: '<subcommand>',
description: description: 'balance: get your balance\n deposit: get address for your deposits\n withdraw ADDRESS AMOUNT: withdraw AMOUNT credits to ADDRESS\n <user> <amount>: mention a user with @ and then the amount to tip them',
"balance: get your balance\n deposit: get address for your deposits\n withdraw ADDRESS AMOUNT: withdraw AMOUNT credits to ADDRESS\n <user> <amount>: mention a user with @ and then the amount to tip them",
process: function(bot) { process: function(bot) {
return; // Tipping is now handled by the separate tipbot(in branch tipbot_dc), no need to to anything here... return; // Tipping is now handled by the separate tipbot(in branch tipbot_dc), no need to to anything here...
} }

View file

@ -1,99 +1,98 @@
let hasPerms = require("../helpers.js").hasPerms; let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require("../helpers.js").inPrivate; let inPrivate = require('../helpers.js').inPrivate;
exports.custom = ["onUserJoin"]; exports.custom = ['onUserJoin'];
exports.onUserJoin = function(bot) { exports.onUserJoin = function(bot) {
bot.on("guildMemberAdd", member => { bot.on('guildMemberAdd', member => {
member.send({ member.send({
embed: { embed: {
title: "*Click here for more info about LBRY!*", title: '*Click here for more info about LBRY!*',
description: description:
"**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n" + '**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n' +
"If you are new to LBRY and would like to learn more, see the links at the end of this message. \n" + 'If you are new to LBRY and would like to learn more, see the links at the end of this message. \n' +
"This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n" + 'This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n' +
"**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient . **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n", '**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient . **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n',
url: "https://lbry.io/what", url: 'https://lbry.io/what',
color: 7976557, color: 7976557,
author: { author: {
name: "Welcome to LBRY Discord Community", name: 'Welcome to LBRY Discord Community',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
member.send({ member.send({
embed: { embed: {
description: description:
"1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n" + '1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n' +
"2. Do not spam, advertise or post referral links \n" + '2. Do not spam, advertise or post referral links \n' +
"3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n" + '3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n' +
"4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n" + '4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n' +
"5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n" + '5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n' +
"6. Do not direct message and LBRY team or mods without being asked to do so \n" + '6. Do not direct message and LBRY team or mods without being asked to do so \n' +
"7. Do not request free LBC, begging will not be tolerated \n", '7. Do not request free LBC, begging will not be tolerated \n',
color: 7976557, color: 7976557,
author: { author: {
name: "Ground rules", name: 'Ground rules',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
member.send({ member.send({
embed: { embed: {
description: description:
"1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n" + '1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n' +
"2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n" + '2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n' +
"3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n" + '3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n' +
"4. You can find the LBRY Block explorer at https://explorer.lbry.io \n" + '4. You can find the LBRY Block explorer at https://explorer.lbry.io \n' +
"5. Want to contribute more? Check out https://lbry.io/faq/contributing \n" + '5. Want to contribute more? Check out https://lbry.io/faq/contributing \n' +
"6. Are you a dev? Check out the #dev channel \n" + '6. Are you a dev? Check out the #dev channel \n' +
"7. Want to share something you published? Post it on the #publishers channel \n", '7. Want to share something you published? Post it on the #publishers channel \n',
color: 7976557, color: 7976557,
author: { author: {
name: "Helpful hints", name: 'Helpful hints',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
member.send({ member.send({
embed: { embed: {
title: "*Click here for more info about LBRY!*", title: '*Click here for more info about LBRY!*',
description: description:
"[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)", '[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)',
url: "https://lbry.io/what", url: 'https://lbry.io/what',
color: 7976557, color: 7976557,
author: { author: {
name: "What is LBRY?", name: 'What is LBRY?',
url: "https://lbry.io/what", url: 'https://lbry.io/what',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
member.send({ member.send({
embed: { embed: {
title: "*Click here to see all LBRY Frequently Asked Questions (FAQ)!*", title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description: description:
"Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)", 'Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)',
url: "https://lbry.io/faq", url: 'https://lbry.io/faq',
color: 7976557, color: 7976557,
author: { author: {
name: "LBRY FAQ", name: 'LBRY FAQ',
url: "https://lbry.io/faq", url: 'https://lbry.io/faq',
icon_url: "https://spee.ch/8/Id5Qoc3w.png" icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
} }
} }
}); });
member.send({ member.send({
embed: { embed: {
title: "*Have you checked out spee.ch yet?!*", title: '*Have you checked out spee.ch yet?!*',
description: description:
"[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistent and decentralized image and video sharing site with the added benefit of being a web-based (works on mobile too!) gateway into the LBRY network. spee.ch can be used to retrieve LBRY images/videos that are free by accessing them through a web browser. \nFor example, if content is located at lbry://loose-cannons-episode1#12c87bb42dd8832167b1e54edf72bbd37bc47622, you can view it on spee.ch at: https://spee.ch/12c87bb42dd8832167b1e54edf72bbd37bc47622/loose-cannons-episode1. You can also view channels on spee.ch, such as: https://spee.ch/@copchronicles:5c039dc7423657e59d78939df72c186e43273675 or https://spee.ch/@MinutePhysics:589276465a23c589801d874f484cc39f307d7ec7 \n\nspee.ch also allows you to create a channel to group your uploads and retreive them easily. These channels are separate from any you may have in the LBRY app since they exist on the spee.ch site via a login process. You can even share your channel name and password so that others can contribute to it.", "[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistent and decentralized image and video sharing site with the added benefit of being a web-based (works on mobile too!) gateway into the LBRY network. spee.ch can be used to retrieve LBRY images/videos that are free by accessing them through a web browser. \nFor example, if content is located at lbry://loose-cannons-episode1#12c87bb42dd8832167b1e54edf72bbd37bc47622, you can view it on spee.ch at: https://spee.ch/12c87bb42dd8832167b1e54edf72bbd37bc47622/loose-cannons-episode1. You can also view channels on spee.ch, such as: https://spee.ch/@copchronicles:5c039dc7423657e59d78939df72c186e43273675 or https://spee.ch/@MinutePhysics:589276465a23c589801d874f484cc39f307d7ec7 \n\nspee.ch also allows you to create a channel to group your uploads and retreive them easily. These channels are separate from any you may have in the LBRY app since they exist on the spee.ch site via a login process. You can even share your channel name and password so that others can contribute to it.",
url: "https://spee.ch/about", url: 'https://spee.ch/about',
color: 7976557, color: 7976557,
author: { author: {
name: "spee.ch", name: 'spee.ch',
url: "https://spee.ch", url: 'https://spee.ch',
icon_url: icon_url: 'http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png'
"http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png"
} }
} }
}); });
@ -101,115 +100,114 @@ exports.onUserJoin = function(bot) {
}; };
exports.commands = [ exports.commands = [
"welcome" // command that is in this file, every command needs it own export as shown below 'welcome' // command that is in this file, every command needs it own export as shown below
]; ];
exports.welcome = { exports.welcome = {
usage: "<@username>", usage: '<@username>',
description: "send welcome message to specified user", description: 'send welcome message to specified user',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
if (inPrivate(msg)) { if (inPrivate(msg)) {
msg.channel.send("command cannot be used in a DM"); msg.channel.send('command cannot be used in a DM');
return; return;
} }
if (suffix == "") { if (suffix == '') {
msg.channel.send("no user defined"); msg.channel.send('no user defined');
return; return;
} }
if (!hasPerms(msg)) { if (!hasPerms(msg)) {
msg.channel.send("You Dont Have Permission To Use This Command!"); msg.channel.send('You Dont Have Permission To Use This Command!');
return; return;
} }
msg.mentions.members.first().send({ msg.mentions.members.first().send({
embed: { embed: {
title: "*Click here for more info about LBRY!*", title: '*Click here for more info about LBRY!*',
description: description:
"**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n" + '**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n' +
"If you are new to LBRY and would like to learn more, see the links at the end of this message. \n" + 'If you are new to LBRY and would like to learn more, see the links at the end of this message. \n' +
"This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n" + 'This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n' +
"**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient, **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n", '**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient, **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n',
url: "https://lbry.io/what", url: 'https://lbry.io/what',
color: 7976557, color: 7976557,
author: { author: {
name: "Welcome to LBRY Discord Community", name: 'Welcome to LBRY Discord Community',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
msg.mentions.members.first().send({ msg.mentions.members.first().send({
embed: { embed: {
description: description:
"1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n" + '1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n' +
"2. Do not spam, advertise or post referral links \n" + '2. Do not spam, advertise or post referral links \n' +
"3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n" + '3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n' +
"4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n" + '4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n' +
"5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n" + '5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n' +
"6. Do not direct message and LBRY team or mods without being asked to do so \n" + '6. Do not direct message and LBRY team or mods without being asked to do so \n' +
"7. Do not request free LBC, begging will not be tolerated \n", '7. Do not request free LBC, begging will not be tolerated \n',
color: 7976557, color: 7976557,
author: { author: {
name: "Ground rules", name: 'Ground rules',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
msg.mentions.members.first().send({ msg.mentions.members.first().send({
embed: { embed: {
description: description:
"1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n" + '1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n' +
"2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n" + '2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n' +
"3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n" + '3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n' +
"4. You can find the LBRY Block explorer at https://explorer.lbry.io \n" + '4. You can find the LBRY Block explorer at https://explorer.lbry.io \n' +
"5. Want to contribute more? Check out https://lbry.io/faq/contributing \n" + '5. Want to contribute more? Check out https://lbry.io/faq/contributing \n' +
"6. Are you a dev? Check out the #dev channel \n" + '6. Are you a dev? Check out the #dev channel \n' +
"7. Want to share something you published? Post it on the #publishers channel \n", '7. Want to share something you published? Post it on the #publishers channel \n',
color: 7976557, color: 7976557,
author: { author: {
name: "Helpful hints", name: 'Helpful hints',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
msg.mentions.members.first().send({ msg.mentions.members.first().send({
embed: { embed: {
title: "*Click here for more info about LBRY!*", title: '*Click here for more info about LBRY!*',
description: description:
"[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)", '[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)',
url: "https://lbry.io/what", url: 'https://lbry.io/what',
color: 7976557, color: 7976557,
author: { author: {
name: "What is LBRY?", name: 'What is LBRY?',
url: "https://lbry.io/what", url: 'https://lbry.io/what',
icon_url: "https://i.imgur.com/yWf5USu.png" icon_url: 'https://i.imgur.com/yWf5USu.png'
} }
} }
}); });
msg.mentions.members.first().send({ msg.mentions.members.first().send({
embed: { embed: {
title: "*Click here to see all LBRY Frequently Asked Questions (FAQ)!*", title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description: description:
"Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)", 'Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)',
url: "https://lbry.io/faq", url: 'https://lbry.io/faq',
color: 7976557, color: 7976557,
author: { author: {
name: "LBRY FAQ", name: 'LBRY FAQ',
url: "https://lbry.io/faq", url: 'https://lbry.io/faq',
icon_url: "https://spee.ch/8/Id5Qoc3w.png" icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
} }
} }
}); });
msg.mentions.members.first().send({ msg.mentions.members.first().send({
embed: { embed: {
title: "*Have you checked out spee.ch yet?!*", title: '*Have you checked out spee.ch yet?!*',
description: description:
"[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistent and decentralized image and video sharing site with the added benefit of being a web-based (works on mobile too!) gateway into the LBRY network. spee.ch can be used to retrieve LBRY images/videos that are free by accessing them through a web browser. \nFor example, if content is located at lbry://loose-cannons-episode1#12c87bb42dd8832167b1e54edf72bbd37bc47622, you can view it on spee.ch at: https://spee.ch/12c87bb42dd8832167b1e54edf72bbd37bc47622/loose-cannons-episode1. You can also view channels on spee.ch, such as: https://spee.ch/@copchronicles:5c039dc7423657e59d78939df72c186e43273675 or https://spee.ch/@MinutePhysics:589276465a23c589801d874f484cc39f307d7ec7 \n\nspee.ch also allows you to create a channel to group your uploads and retreive them easily. These channels are separate from any you may have in the LBRY app since they exist on the spee.ch site via a login process. You can even share your channel name and password so that others can contribute to it.", "[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistent and decentralized image and video sharing site with the added benefit of being a web-based (works on mobile too!) gateway into the LBRY network. spee.ch can be used to retrieve LBRY images/videos that are free by accessing them through a web browser. \nFor example, if content is located at lbry://loose-cannons-episode1#12c87bb42dd8832167b1e54edf72bbd37bc47622, you can view it on spee.ch at: https://spee.ch/12c87bb42dd8832167b1e54edf72bbd37bc47622/loose-cannons-episode1. You can also view channels on spee.ch, such as: https://spee.ch/@copchronicles:5c039dc7423657e59d78939df72c186e43273675 or https://spee.ch/@MinutePhysics:589276465a23c589801d874f484cc39f307d7ec7 \n\nspee.ch also allows you to create a channel to group your uploads and retreive them easily. These channels are separate from any you may have in the LBRY app since they exist on the spee.ch site via a login process. You can even share your channel name and password so that others can contribute to it.",
url: "https://spee.ch/about", url: 'https://spee.ch/about',
color: 7976557, color: 7976557,
author: { author: {
name: "spee.ch", name: 'spee.ch',
url: "https://spee.ch", url: 'https://spee.ch',
icon_url: icon_url: 'http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png'
"http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png"
} }
} }
}); });

File diff suppressed because it is too large Load diff

View file

@ -19,11 +19,11 @@
"wget": "^0.0.1" "wget": "^0.0.1"
}, },
"scripts": { "scripts": {
"prettier": "prettier * --write", "prettier": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
"build": "babel bot -d dist", "build": "babel bot -d dist",
"prod": "babel bot -d dist & node dist/bot.js", "prod": "babel bot -d dist & node dist/bot.js",
"lint": "prettier --write bot/**/*.js", "lint": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
"precommit": "prettier --write bot/**/*.js" "precommit": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240"
}, },
"devDependencies": { "devDependencies": {
"husky": "^0.14.3", "husky": "^0.14.3",