Merge pull request #116 from nikooo777/commands-cleanup

Commands cleanup
This commit is contained in:
Niko 2017-12-19 02:12:36 +01:00 committed by GitHub
commit 065facf799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 666 additions and 748 deletions

View file

@ -1,38 +1,36 @@
"use strict";
'use strict';
// Load up libraries
const Discord = require("discord.js");
const Discord = require('discord.js');
// Load config!
let config = require("config");
config = config.get("bot");
let config = require('config');
config = config.get('bot');
//load modules
const claimbot = require("./modules/claimbot.js");
const claimbot = require('./modules/claimbot.js');
const commandsV2 = require('./modules/commandsV2.js');
var aliases;
try {
aliases = require("./alias.json");
aliases = require('./alias.json');
} catch (e) {
//No aliases defined
aliases = {
test: {
process: function(bot, msg) {
msg.channel.send("test");
msg.channel.send('test');
}
}
};
}
var commands = {
ping: {
description: "responds pong, useful for checking if bot is alive",
description: 'responds pong, useful for checking if bot is alive',
process: async function(bot, msg, suffix) {
let m = await msg.channel.send(msg.author + " Ping?");
m.edit(
`Pong! Latency is ${m.createdTimestamp -
msg.createdTimestamp}ms. API Latency is ${Math.round(bot.ping)}ms`
);
let m = await msg.channel.send(msg.author + ' Ping?');
m.edit(`Pong! Latency is ${m.createdTimestamp - msg.createdTimestamp}ms. API Latency is ${Math.round(bot.ping)}ms`);
if (suffix) {
msg.channel.send("note that !ping takes no arguments!");
msg.channel.send('note that !ping takes no arguments!');
}
}
}
@ -40,48 +38,36 @@ var commands = {
var bot = new Discord.Client();
bot.on("ready", function() {
console.log(
"Logged in! Serving in " + bot.guilds.array().length + " servers"
);
require("./plugins.js").init();
console.log("type " + config.prefix + "help in Discord for a commands list.");
bot.user.setGame(config.prefix + "help");
bot.on('ready', function() {
console.log('Logged in! Serving in ' + bot.guilds.array().length + ' servers');
require('./plugins.js').init();
console.log('type ' + config.prefix + 'help in Discord for a commands list.');
bot.user.setGame(config.prefix + 'help');
//initialize the claimbot (content bot)
claimbot.init(bot);
//initialize the commandsBot
commandsV2.init(bot);
});
bot.on("disconnected", function() {
console.log("Disconnected!");
bot.on('disconnected', function() {
console.log('Disconnected!');
process.exit(1); //exit node.js with an error
});
function checkMessageForCommand(msg, isEdit) {
//check if message is a command
if (msg.author.id != bot.user.id && msg.content.startsWith(config.prefix)) {
console.log(
"treating " +
msg.content +
" from UserID:" +
msg.author +
" || UserName: " +
msg.author.username +
" as command"
);
var cmdTxt = msg.content.split(" ")[0].substring(config.prefix.length);
var suffix = msg.content.substring(
cmdTxt.length + config.prefix.length + 1
); //add one for the ! and one for the space
console.log('treating ' + msg.content + ' from UserID:' + msg.author + ' || UserName: ' + msg.author.username + ' as command');
var cmdTxt = msg.content.split(' ')[0].substring(config.prefix.length);
var suffix = msg.content.substring(cmdTxt.length + config.prefix.length + 1); //add one for the ! and one for the space
if (msg.isMentioned(bot.user)) {
try {
cmdTxt = msg.content.split(" ")[1];
suffix = msg.content.substring(
bot.user.mention().length + cmdTxt.length + config.prefix.length + 1
);
cmdTxt = msg.content.split(' ')[1];
suffix = msg.content.substring(bot.user.mention().length + cmdTxt.length + config.prefix.length + 1);
} catch (e) {
//no command
msg.channel.send("Yes?");
msg.channel.send('Yes?');
return;
}
}
@ -91,49 +77,49 @@ function checkMessageForCommand(msg, isEdit) {
} else {
var cmd = commands[cmdTxt];
}
if (cmdTxt === "help") {
if (cmdTxt === 'help') {
//help is special since it iterates over the other commands
if (suffix) {
var cmds = suffix.split(" ").filter(function(cmd) {
var cmds = suffix.split(' ').filter(function(cmd) {
return commands[cmd];
});
var info = "";
var info = '';
for (var i = 0; i < cmds.length; i++) {
var cmd = cmds[i];
info += "**" + config.prefix + cmd + "**";
info += '**' + config.prefix + cmd + '**';
var usage = commands[cmd].usage;
if (usage) {
info += " " + usage;
info += ' ' + usage;
}
var description = commands[cmd].description;
if (description instanceof Function) {
description = description();
}
if (description) {
info += "\n\t" + description;
info += '\n\t' + description;
}
info += "\n";
info += '\n';
}
msg.channel.send(info);
} else {
msg.author.send("**Available Commands:**").then(function() {
var batch = "";
msg.author.send('**Available Commands:**').then(function() {
var batch = '';
var sortedCommands = Object.keys(commands).sort();
for (var i in sortedCommands) {
var cmd = sortedCommands[i];
var info = "**" + config.prefix + cmd + "**";
var info = '**' + config.prefix + cmd + '**';
var usage = commands[cmd].usage;
if (usage) {
info += " " + usage;
info += ' ' + usage;
}
var description = commands[cmd].description;
if (description instanceof Function) {
description = description();
}
if (description) {
info += "\n\t" + description;
info += '\n\t' + description;
}
var newBatch = batch + "\n" + info;
var newBatch = batch + '\n' + info;
if (newBatch.length > 1024 - 8) {
//limit message length
msg.author.send(batch);
@ -152,16 +138,14 @@ function checkMessageForCommand(msg, isEdit) {
try {
cmd.process(bot, msg, suffix, isEdit);
} catch (e) {
var msgTxt = "command " + cmdTxt + " failed :(";
var msgTxt = 'command ' + cmdTxt + ' failed :(';
if (config.debug) {
msgTxt += "\n" + e.stack;
msgTxt += '\n' + e.stack;
}
msg.channel.send(msgTxt);
}
} else {
msg.channel
.send(cmdTxt + " not recognized as a command!")
.then(message => message.delete(10000));
msg.channel.send(cmdTxt + ' not recognized as a command!').then(message => message.delete(10000));
}
} else {
//message isn't a command or is from us
@ -171,14 +155,14 @@ function checkMessageForCommand(msg, isEdit) {
}
if (msg.author != bot.user && msg.isMentioned(bot.user)) {
msg.channel.send("yes?"); //using a mention here can lead to looping
msg.channel.send('yes?'); //using a mention here can lead to looping
} else {
}
}
}
bot.on("message", msg => checkMessageForCommand(msg, false));
bot.on("messageUpdate", (oldMessage, newMessage) => {
bot.on('message', msg => checkMessageForCommand(msg, false));
bot.on('messageUpdate', (oldMessage, newMessage) => {
checkMessageForCommand(newMessage, true);
});

View file

@ -1,686 +0,0 @@
"use strict";
let config = require("config");
let miningChannel = config.get("Channels").mining;
let randomChannel = config.get("Channels").random;
let verificationChannel = config.get("Channels").verification;
exports.commands = [
"helpcommands",
"what",
"begging",
"beta",
"github",
"appdownload",
"daemondownload",
"directories",
"faq",
"name",
"mining",
"pricestance",
"youtuber",
"publish",
"random",
"referrals",
"rewards",
"rewardsvsreferrals",
"cc",
"verify",
"verification",
"logfile",
"backup",
"startup",
"streamingissues",
"ports",
"migrate",
"tipping",
"email",
"cli",
"ipfstorrent"
"shapeshift"
"youtube"
"transactions"
];
exports.helpcommands = {
usage: " ",
description:
"Displays Helpful Commands:\n!what, !beta, !begging, !github, !appdownload, !daemondownload, !directories, !faq, !name, !mining, !pricestance, !youtuber, !publish, !random, !referrals, !rewards, !rewardsvsreferrals, !cc, !verify, !verification, !logfile, !backup, !startup, !streamingissues, !ports, !migrate, !tipping, !email, !cli, !ipfstorrent, !shapeshift, !youtube, !transactions",
process: function(bot, msg) {
msg.channel.send({
embed: {
description:
"**!what, !beta, !begging, !github, !appdownload, !daemondownload, !directories, !faq, !name, !mining, !pricestance, !youtuber, !publish, !random, !referrals, !rewards, !rewardsvsreferrals, !cc, !verify, !verification, !logfile, !backup, !startup, !streamingissues, !ports, !migrate, !tipping, !email, !cli, !ipfstorrent, !shapeshift, !youtube, !transactions**",
color: 7976557,
author: {
name: "List of Helpful LBRY Commands",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
}
});
}
};
exports.what = {
usage: " ",
description: "What is Lbry?",
process: function(bot, msg) {
const embed = {
title: "*Click Here for more Info!*",
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[_**Get the App here**_](https://lbry.io/get)",
url: "https://lbry.io/what",
color: 7976557,
author: {
name: "What is LBRY?",
url: "https://lbry.io/what",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.appdownload = {
usage: " ",
description: "LBRY-app Installers",
process: function(bot, msg) {
const embed = {
description:
"**Installers for the LBRY Application are available for download** [**HERE**](https://lbry.io/get)",
color: 7976557,
author: {
name: "Get The App",
url: "https://lbry.io/get",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.begging = {
usage: " ",
description: "Dont Request Free Coins Message",
process: function(bot, msg) {
const embed = {
description:
"**Please don't request free coins or invites, we have a strict policy against begging. Further offenses will result in removal from the chat.**",
color: 7976557,
author: {
name: "BEGGING!",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.beta = {
usage: " ",
description: "beta message",
process: function(bot, msg) {
const embed = {
description:
"Even though LBRY is in Open Beta, it's still beta software! There will be bugs and issues to be worked out, thanks for your patience!",
color: 7976557,
author: {
name: "Open Beta",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.github = {
usage: " ",
description: "Lbry Github",
process: function(bot, msg) {
const embed = {
description:
"The official github for LBRY is [github.com/lbryio](https://github.com/lbryio)",
color: 7976557,
author: {
name: "GitHub",
url: "https://github.com/lbryio",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.daemondownload = {
usage: " ",
description: "LBRY Daemon Installers",
process: function(bot, msg) {
const embed = {
description:
"Installers for the LBRY Daemon are available for download [**HERE**](https://github.com/lbryio/lbry/releases) ",
color: 7976557,
author: {
name: "Daemon Download",
url: "https://github.com/lbryio/lbry/releases",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.directories = {
usage: " ",
description: "Lbry-app Directories",
process: function(bot, msg) {
const embed = {
description:
"You can find details about the folders your LBRY files are stored in at [lbry.io/faq/lbry-directories](https://lbry.io/faq/lbry-directories)",
color: 7976557,
author: {
name: "Directories",
url: "https://lbry.io/faq/lbry-directories",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.faq = {
usage: " ",
description: "LBRY F.A.Q.",
process: function(bot, msg) {
const embed = {
description:
"These questions and many more have been answered on the [F.A.Q Page](https://lbry.io/faq/)",
color: 7976557,
author: {
name: "F.A.Q",
url: "https://lbry.io/faq/",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.name = {
usage: " ",
description: "Change Name Message",
process: function(bot, msg) {
const embed = {
description:
"Hey, glad to see you love LBRY so much, but for the safety of our users we ask that you avoid using discord names that include the word lbry. This is to prevent impersonation and scams.",
color: 7976557,
author: {
name: "Discord Username",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.mining = {
usage: " ",
description: "Mining LBRY Credits (LBC)",
process: function(bot, msg) {
var message =
"We have a dedicated channel for mining discussion, feel free to join <#" +
miningChannel +
">";
msg.channel.send(message);
}
};
exports.pricestance = {
usage: " ",
description: "Our Stance on LBC Price",
process: function(bot, msg) {
const embed = {
description:
"Details about our stance on price can be found here: [lbry.io/news/acryptypical](https://lbry.io/news/acryptypical)",
color: 7976557,
author: {
name: "CEO's Stance on Price",
url: "https://lbry.io/news/acryptypical",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.youtuber = {
usage: " ",
description: "Are you a Youtuber curious about LBRY?",
process: function(bot, msg) {
const embed = {
description:
"Are you a Youtuber curious about LBRY? Have a look at [lbry.io/youtube](https://lbry.io/youtube)",
color: 7976557,
author: {
name: "Are you a Youtuber?",
url: "https://lbry.io/youtube",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.publish = {
usage: " ",
description: "How To Publish on LBRY?",
process: function(bot, msg) {
const embed = {
description:
"We've created a small guide to help with the Publishing features of LBRY, check it out here: [lbry.io/faq/how-to-publish](https://lbry.io/faq/how-to-publish)",
color: 7976557,
author: {
name: "How to Publish",
url: "https://lbry.io/faq/how-to-publish",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.random = {
usage: " ",
description: "Off-Topic Message",
process: function(bot, msg) {
var message =
"Please keep conversation on topic, or move random conversations to #" +
randomChannel +
" if you wish to continue";
msg.channel.send(message);
}
};
exports.referrals = {
usage: " ",
description: "What are Referrals?",
process: function(bot, msg) {
const embed = {
description:
"Please see [lbry.io/faq/referrals](https://lbry.io/faq/referrals) - referral redemptions are currently in test mode and limited to one. But you can see your entire referral history in your LBRY app.",
color: 7976557,
author: {
name: "Referals",
url: "https://lbry.io/faq/referrals",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.rewards = {
usage: " ",
description: "What are Rewards?",
process: function(bot, msg) {
const embed = {
description:
"[Rewards](https://lbry.io/faq/rewards) are given to legitimate users who are using the system (and in turn are testing things for us). In order to redeem rewards, you may need to verify your identity through a Credit Card or other manual methods.\n Please see [lbry.io/faq/identity-requirements](https://lbry.io/faq/identity-requirements)",
color: 7976557,
author: {
name: "Rewards",
url: "https://lbry.io/faq/rewards",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.rewardsvsreferrals = {
usage: " ",
description: "What the Difference Between Rewards & Referrals?",
process: function(bot, msg) {
const embed = {
description:
"Rewards are different to referral bonuses. Rewards are given for testing the LBRY software and system. Referrals are given for sharing LBRY with the masses.",
color: 7976557,
author: {
name: "Rewards Vs. Referrals",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.cc = {
usage: " ",
description: "Credit Card Verification?",
process: function(bot, msg) {
var message =
"In an effort to limit abuse, newly invited LBRY users will be required to verify their identity via a Credit Card or by a manual verification process in order to be eligible for Rewards. Prepaid or Virtual credit cards are disallowed. Certain countries (where we've previously seen abuse) are being denied, but that list may expand later on. If you use Tor/Proxy/VPN, you also may be denied. If credit card verification does not work for you, please go to the <#" +
verificationChannel +
"> channel for assistance.\n**Verification is purely optional and ONLY relevant for Rewards, the app can be used without providing CC information**\n**Please See:https://lbry.io/faq/identity-requirements**";
msg.channel.send(message);
}
};
exports.verify = {
usage: " ",
description: "How to Verify?",
process: function(bot, msg) {
const embed = {
description:
"Please download the latest version from [HERE](https://lbry.io/get) Upon install, you'll be greeted with a welcome message. If you already had the App installed, then go to the wallet (bank icon in the top right) > Rewards - this should show your current status. New users will need to verify in order to access rewards. Type !cc or !verification for more information.",
color: 7976557,
author: {
name: "How To Verify?",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.verification = {
usage: " ",
description: "Verification Help Message",
process: function(bot, msg) {
var message =
"If you would like to be verified go to <#" +
verificationChannel +
">. After joining, post that you would like verification and a mod will get to your request as soon as possible. We appreciate your patience. Only one account per person is allowed access to LBRY Rewards. Check out our [YouTube Sync](https://lbry.io/faq/youtube) for assistance with the YouTube Sync rewards verification method.";
msg.channel.send(message);
}
};
exports.logfile = {
usage: " ",
description: "How to find LBRY-app Log File?",
process: function(bot, msg) {
const embed = {
description:
"You can find your log files by following the guide [HERE](https://lbry.io/faq/how-to-find-lbry-log-file)",
color: 7976557,
author: {
name: "How to find my LogFile?",
url: "https://lbry.io/faq/how-to-find-lbry-log-file",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.backup = {
usage: " ",
description: "How to Backup the Wallet",
process: function(bot, msg) {
const embed = {
description:
"Please see this guide on how to backup your wallet: [lbry.io/faq/how-to-backup-wallet](https://lbry.io/faq/how-to-backup-wallet)",
color: 7976557,
author: {
name: "How to Backup my Wallet?",
url: "https://lbry.io/faq/how-to-backup-wallet",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.startupissues = {
usage: " ",
description: "Startup Troubleshooting?",
process: function(bot, msg) {
const embed = {
description:
"Please see [lbry.io/faq/startup-troubleshooting](https://lbry.io/faq/startup-troubleshooting) if you are having trouble getting LBRY to start correctly.",
color: 7976557,
author: {
name: "Startup Troubleshooting",
url: "https://lbry.io/faq/startup-troubleshooting",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.streamingissues = {
usage: " ",
description: "Unable To Stream?",
process: function(bot, msg) {
const embed = {
description:
"Please see [lbry.io/faq/unable-to-stream](https://lbry.io/faq/unable-to-stream) if you are experiencing problems viewing **ANY** LBRY content.",
color: 7976557,
author: {
name: "Streaming Troubleshooting",
url: "https://lbry.io/faq/unable-to-stream",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.ports = {
usage: " ",
description: "LBRY Ports",
process: function(bot, msg) {
const embed = {
description:
"The daemon uses ports **3333** and **4444**. May interfere with mining software. Start miner after the app and you should be okay. Also these ports need to be port forwarded on your router. Google is your friend there. \n **Please see this tutorial on how to change ports : [lbry.io/faq/how-to-change-port](https://lbry.io/faq/how-to-change-port)**",
color: 7976557,
author: {
name: "Ports",
url: "https://lbry.io/faq/how-to-change-port",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.migrate = {
usage: " ",
description: "How to Migrate your Wallet/Data",
process: function(bot, msg) {
const embed = {
description:
"Please see [lbry.io/faq/backup-data](https://lbry.io/faq/backup-data) for instructions on how to backup and/or migrate your LBRY data",
color: 7976557,
author: {
name: "How To Backup/Migrate LBRY Data?",
url: "https://lbry.io/faq/backup-data",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.tipping = {
usage: " ",
description: "Details About LBRY-app Tipping",
process: function(bot, msg) {
const embed = {
description:
"Please see [lbry.io/faq/tipping](https://lbry.io/faq/tipping) for details about tipping in the LBRY-App",
color: 7976557,
author: {
name: "LBRY-App Tipping?",
url: "https://lbry.io/faq/tipping",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.email = {
usage: " ",
description: "How to change Email in LBRY-app?",
process: function(bot, msg) {
const embed = {
description:
"If you need to change your LBRY connected email, please see instructions [HERE](https://lbry.io/faq/how-to-change-email)",
color: 7976557,
author: {
name: "LBRY-App Change connected E-mail?",
url: "https://lbry.io/faq/how-to-change-email",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.cli = {
usage: " ",
description: "How to interact with LBRY CLI?",
process: function(bot, msg) {
const embed = {
description:
"If you are interested in interacting with the LBRY protocol via commands, check out [lbry.io/faq/how-to-cli](https://lbry.io/faq/how-to-cli)",
color: 7976557,
author: {
name: "Interact with the LBRY CLI",
url: "https://lbry.io/faq/how-to-cli",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.ipfstorrent = {
usage: " ",
description: "How is LBRY different from IPFS / BitTorrent?",
process: function(bot, msg) {
const embed = {
description:
"If you are interested in how LBRY is different from IPFS or BitTorrent, check out [lbry.io/faq/different-ipfs](https://lbry.io/faq/different-ipfs)",
color: 7976557,
author: {
name: "How is LBRY different from IPFS / BitTorrent?",
url: "https://lbry.io/faq/different-ipfs",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.shapeshift = {
usage: " ",
description: "How can I convert my crypto into LBC?",
process: function(bot, msg) {
const embed = {
description:
"Please see this guide on how to convert your crypto into LBC: [lbry.io/faq/shapeshift](https://lbry.io/faq/shapeshift)",
color: 7976557,
author: {
name: "How can I convert my crypto into LBC?",
url: "https://lbry.io/faq/shapeshift",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.youtube = {
usage: " ",
description: "What is YouTube Sync?",
process: function(bot, msg) {
const embed = {
description:
"Please see this guide on how youtube sync works, check out [lbry.io/faq/youtube](https://lbry.io/faq/youtube)",
color: 7976557,
author: {
name: "What is YouTube Sync?",
url: "https://lbry.io/faq/youtube",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};
exports.transactions = {
usage: " ",
description: "What types of LBRY transactions are there?",
process: function(bot, msg) {
const embed = {
description:
"Please see this guide on [transaction types](https://lbry.io/faq/transaction-types)",
color: 7976557,
author: {
name: "What types of LBRY transactions are there?",
url: "https://lbry.io/faq/transaction-types",
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({
embed
});
}
};

58
bot/modules/commandsV2.js Normal file
View file

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

562
config/commands.json Normal file
View file

@ -0,0 +1,562 @@
{
"!helpcommands": {
"usage": "",
"description": "Displays Helpful Commands",
"operation": "none",
"bundle": {
"url": "",
"title": "",
"description": "filled at runtime",
"color": 7976557,
"author": {
"name": "List of Helpful LBRY Commands",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!what": {
"usage": "",
"description": "What is Lbry?",
"operation": "send",
"bundle": {
"url": "https://lbry.io/what",
"title": "*Click Here for more Info!*",
"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[_**Get the App here**_](https://lbry.io/get)",
"color": 7976557,
"author": {
"name": "What is LBRY?",
"url": "https://lbry.io/what",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!begging": {
"usage": "",
"description": "Dont Request Free Coins Message",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "**Please don't request free coins or invites, we have a strict policy against begging. Further offenses will result in removal from the chat.**",
"color": 7976557,
"author": {
"name": "BEGGING!",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!beta": {
"usage": "",
"description": "beta message",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Even though LBRY is in Open Beta, it's still beta software! There will be bugs and issues to be worked out, thanks for your patience!",
"color": 7976557,
"author": {
"name": "Open Beta",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!github": {
"usage": "",
"description": "Lbry Github",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "The official github for LBRY is [github.com/lbryio](https://github.com/lbryio)",
"color": 7976557,
"author": {
"name": "GitHub",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!appdownload": {
"usage": "",
"description": "LBRY-app Installers",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "**Installers for the LBRY Application are available for download** [**HERE**](https://lbry.io/get)",
"color": 7976557,
"author": {
"name": "Get The App",
"url": "http://lbry.io/get?auto=1",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!daemondownload": {
"usage": "",
"description": "LBRY Daemon Installers",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Installers for the LBRY Daemon are available for download [**HERE**](https://github.com/lbryio/lbry/releases)",
"color": 7976557,
"author": {
"name": "Daemon Download",
"url": "https://github.com/lbryio/lbry/releases",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!directories": {
"usage": "",
"description": "Lbry-app Directories",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "You can find details about the folders your LBRY files are stored in at [lbry.io/faq/lbry-directories](https://lbry.io/faq/lbry-directories)",
"color": 7976557,
"author": {
"name": "Directories",
"url": "https://lbry.io/faq/lbry-directories",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!faq": {
"usage": "",
"description": "LBRY F.A.Q.",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "These questions and many more have been answered on the [F.A.Q Page](https://lbry.io/faq/)",
"color": 7976557,
"author": {
"name": "F.A.Q",
"url": "https://lbry.io/faq/",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!name": {
"usage": "",
"description": "Change Name Message",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Hey, glad to see you love LBRY so much, but for the safety of our users we ask that you avoid using discord names that include the word lbry. This is to prevent impersonation and scams.",
"color": 7976557,
"author": {
"name": "Discord Username",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!mining": {
"usage": "",
"description": "Mining LBRY Credits (LBC)",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "We have a dedicated channel for mining discussion, feel free to join <#363049669636390913>",
"color": 7976557,
"author": {
"name": "Mining",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!pricestance": {
"usage": "",
"description": "Our Stance on LBC Price",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Details about our stance on price can be found here: [lbry.io/news/acryptypical](https://lbry.io/news/acryptypical)",
"color": 7976557,
"author": {
"name": "CEO's Stance on Price",
"url": "https://lbry.io/news/acryptypical",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!youtuber": {
"usage": "",
"description": "Are you a Youtuber curious about LBRY?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Are you a Youtuber curious about LBRY? Have a look at [lbry.io/youtube](https://lbry.io/youtube)",
"color": 7976557,
"author": {
"name": "Are you a Youtuber?",
"url": "https://lbry.io/youtube",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!publish": {
"usage": "",
"description": "How To Publish on LBRY?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "We've created a small guide to help with the Publishing features of LBRY, check it out here: [lbry.io/faq/how-to-publish](https://lbry.io/faq/how-to-publish)",
"color": 7976557,
"author": {
"name": "",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!random": {
"usage": "",
"description": "Off-Topic Message",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please keep conversation on topic, or move random conversations to #363084227518136322 if you wish to continue",
"color": 7976557,
"author": {
"name": "Random",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!referrals": {
"usage": "",
"description": "What are Referrals?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see [lbry.io/faq/referrals](https://lbry.io/faq/referrals) - referral redemptions are currently in test mode and limited to one. But you can see your entire referral history in your LBRY app.",
"color": 7976557,
"author": {
"name": "Referals",
"url": "https://lbry.io/faq/referrals",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!rewards": {
"usage": "",
"description": "What are Rewards?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "[Rewards](https://lbry.io/faq/rewards) are given to legitimate users who are using the system (and in turn are testing things for us). In order to redeem rewards, you may need to verify your identity through a Credit Card or other manual methods.\n Please see [lbry.io/faq/identity-requirements](https://lbry.io/faq/identity-requirements)",
"color": 7976557,
"author": {
"name": "Rewards",
"url": "https://lbry.io/faq/rewards",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!rewardsvsreferrals": {
"usage": "",
"description": "What the Difference Between Rewards & Referrals?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Rewards are different to referral bonuses. Rewards are given for testing the LBRY software and system. Referrals are given for sharing LBRY with the masses.",
"color": 7976557,
"author": {
"name": "Rewards Vs. Referrals",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!cc": {
"usage": "",
"description": "Credit Card Verification?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "In an effort to limit abuse, newly invited LBRY users will be required to verify their identity via a Credit Card or by a manual verification process in order to be eligible for Rewards. Prepaid or Virtual credit cards are disallowed. Certain countries (where we've previously seen abuse) are being denied, but that list may expand later on. If you use Tor/Proxy/VPN, you also may be denied. If credit card verification does not work for you, please go to the <#363050496023592961> channel for assistance.\n**Verification is purely optional and ONLY relevant for Rewards, the app can be used without providing CC information**\n**Please See:https://lbry.io/faq/identity-requirements**",
"color": 7976557,
"author": {
"name": "Credit Card Verification",
"url": "https://lbry.io/faq/identity-requirements",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!verify": {
"usage": "",
"description": "How to Verify?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please download the latest version from [HERE](https://lbry.io/get) Upon install, you'll be greeted with a welcome message. If you already had the App installed, then go to the wallet (bank icon in the top right) > Rewards - this should show your current status. New users will need to verify in order to access rewards. Type !cc or !verification for more information.",
"color": 7976557,
"author": {
"name": "How To Verify?",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!verification": {
"usage": "",
"description": "Verification Help Message",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "If you would like to be verified go to <#363050496023592961>. After joining, post that you would like verification and a mod will get to your request as soon as possible. We appreciate your patience. Only one account per person is allowed access to LBRY Rewards. Check out our [YouTube Sync](https://lbry.io/faq/youtube) for assistance with the YouTube Sync rewards verification method.",
"color": 7976557,
"author": {
"name": "Rewards Verification",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!logfile":{
"usage": "",
"description": "How to find LBRY-app Log File?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "You can find your log files by following the guide [HERE](https://lbry.io/faq/how-to-find-lbry-log-file)",
"color": 7976557,
"author": {
"name": "How to find my LogFile?",
"url": "https://lbry.io/faq/how-to-find-lbry-log-file",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!backup": {
"usage": "",
"description": "How to Backup the Wallet",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see this guide on how to backup your wallet: [lbry.io/faq/how-to-backup-wallet](https://lbry.io/faq/how-to-backup-wallet)",
"color": 7976557,
"author": {
"name": "How to Backup my Wallet?",
"url": "https://lbry.io/faq/how-to-backup-wallet",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!startup": {
"usage": "",
"description": "Startup Troubleshooting?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see [lbry.io/faq/startup-troubleshooting](https://lbry.io/faq/startup-troubleshooting) if you are having trouble getting LBRY to start correctly.",
"color": 7976557,
"author": {
"name": "Startup Troubleshooting",
"url": "https://lbry.io/faq/startup-troubleshooting",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!streamingissues": {
"usage": "",
"description": "Unable To Stream?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see [lbry.io/faq/unable-to-stream](https://lbry.io/faq/unable-to-stream) if you are experiencing problems viewing **ANY** LBRY content.",
"color": 7976557,
"author": {
"name": "Streaming Troubleshooting",
"url": "https://lbry.io/faq/unable-to-stream",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!ports": {
"usage": "",
"description": "LBRY Ports",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "The daemon uses ports **3333** and **4444**. May interfere with mining software. Start miner after the app and you should be okay. Also these ports need to be port forwarded on your router. Google is your friend there. \n **Please see this tutorial on how to change ports : [lbry.io/faq/how-to-change-port](https://lbry.io/faq/how-to-change-port)**",
"color": 7976557,
"author": {
"name": "Ports",
"url": "https://lbry.io/faq/how-to-change-port",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!migrate":{
"usage": "",
"description": "How to Migrate your Wallet/Data",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see [lbry.io/faq/backup-data](https://lbry.io/faq/backup-data) for instructions on how to backup and/or migrate your LBRY data",
"color": 7976557,
"author": {
"name": "How To Backup/Migrate LBRY Data?",
"url": "https://lbry.io/faq/backup-data",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!tipping": {
"usage": "",
"description": "Details About LBRY-app Tipping",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see [lbry.io/faq/tipping](https://lbry.io/faq/tipping) for details about tipping in the LBRY-App",
"color": 7976557,
"author": {
"name": "LBRY-App Tipping?",
"url": "https://lbry.io/faq/tipping",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!email": {
"usage": "",
"description": "How to change Email in LBRY-app?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "If you need to change your LBRY connected email, please see instructions [HERE](https://lbry.io/faq/how-to-change-email)",
"color": 7976557,
"author": {
"name": "LBRY-App Change connected E-mail?",
"url": "https://lbry.io/faq/how-to-change-email",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!cli": {
"usage": "",
"description": "How to interact with LBRY CLI?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "If you are interested in interacting with the LBRY protocol via commands, check out [lbry.io/faq/how-to-cli](https://lbry.io/faq/how-to-cli)",
"color": 7976557,
"author": {
"name": "Interact with the LBRY CLI",
"url": "https://lbry.io/faq/how-to-cli",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!ipfstorrent": {
"usage": "",
"description": "How is LBRY different from IPFS / BitTorrent?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "If you are interested in how LBRY is different from IPFS or BitTorrent, check out [lbry.io/faq/different-ipfs](https://lbry.io/faq/different-ipfs)",
"color": 7976557,
"author": {
"name": "How is LBRY different from IPFS / BitTorrent?",
"url": "https://lbry.io/faq/different-ipfs",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!shapeshift": {
"usage": "",
"description": "How can I convert my crypto into LBC?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see this guide on how to convert your crypto into LBC: [lbry.io/faq/shapeshift](https://lbry.io/faq/shapeshift)",
"color": 7976557,
"author": {
"name": "How can I convert my crypto into LBC?",
"url": "https://lbry.io/faq/shapeshift",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!youtube": {
"usage": "",
"description": "What is YouTube Sync?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see this guide on how youtube sync works, check out [lbry.io/faq/youtube](https://lbry.io/faq/youtube)",
"color": 7976557,
"author": {
"name": "What is YouTube Sync?",
"url": "https://lbry.io/faq/youtube",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!transactions": {
"usage": "",
"description": "What types of LBRY transactions are there?",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Please see this guide on [transaction types](https://lbry.io/faq/transaction-types)",
"color": 7976557,
"author": {
"name": "What types of LBRY transactions are there?",
"url": "https://lbry.io/faq/transaction-types",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
},
"!tipbot": {
"usage": "",
"description": "Tipbot Help Message",
"operation": "send",
"bundle": {
"url": "",
"title": "",
"description": "Type !tip help to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC) go to <#369896313082478594>. After joining,please type `!tip help` for more assistance. This channel should be used to talk to bots in order to avoid spamming other channels.",
"color": 7976557,
"author": {
"name": "Tipbot Help Message",
"url": "",
"icon_url": "https://i.imgur.com/yWf5USu.png"
}
}
}
}