Merge pull request #338 from LBRYFoundation/member-fetch-changes

Mass Updates to fix a bunch of issues
This commit is contained in:
Ralph 2021-09-13 11:50:54 -04:00 committed by GitHub
commit c307596ec4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 2157 additions and 1179 deletions

View file

@ -1,15 +1,14 @@
'use strict';
// Load up libraries
const Discord = require('discord.js');
const { Client, Intents } = require('discord.js');
const neededIntents = new Intents(32767);
// Load config!
let config = require('config');
config = config.get('bot');
let genconfig = require('config');
//load modules
const claimbot = require('./modules/claimbot.js');
const commandsV2 = require('./modules/commandsV2.js');
const supportbot = require('./modules/supportbot.js');
let aliases;
try {
@ -30,7 +29,7 @@ let commands = {
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`);
m.edit(`Pong! Latency is ${m.createdTimestamp - msg.createdTimestamp}ms. WebSocket Latency is ${bot.ws.ping}ms`);
if (suffix) {
msg.channel.send('note that !ping takes no arguments!');
}
@ -38,22 +37,16 @@ let commands = {
}
};
let bot = new Discord.Client();
const bot = new Client({ intents: [neededIntents] });
bot.on('ready', function() {
console.log('Logged in! Serving in ' + bot.guilds.cache.size + ' servers');
require('./plugins.js').init();
console.log('type ' + config.prefix + 'help in Discord for a commands list.');
bot.user.setActivity(config.prefix + 'help', { type: 'LISTENING' }).catch(console.error);
bot.user.setActivity(config.prefix + 'help', { type: 'LISTENING' });
//initialize the claimbot (content bot)
if (genconfig.get('claimbot').enabled) {
claimbot.init(bot);
}
//initialize the commandsBot
commandsV2.init(bot);
//initialize the support bot
supportbot.init(bot);
});
process.on('unhandledRejection', err => {
@ -82,7 +75,6 @@ function checkMessageForCommand(msg, isEdit) {
suffix = msg.content.substring(bot.user.mention().length + cmdTxt.length + config.prefix.length + 1);
} catch (e) {
//no command
msg.channel.send('Yes?');
return;
}
}
@ -177,7 +169,7 @@ function checkMessageForCommand(msg, isEdit) {
}
}
bot.on('message', msg => checkMessageForCommand(msg, false));
bot.on('messageCreate', msg => checkMessageForCommand(msg, false));
bot.on('messageUpdate', (oldMessage, newMessage) => {
checkMessageForCommand(newMessage, true);
});

View file

@ -1,135 +0,0 @@
'use strict';
let discordBot;
let moment = require('moment');
let config = require('config');
let channels = config.get('claimbot').channels;
const Discord = require('discord.js');
const request = require('request');
module.exports = {
init: init
};
function init(discordBot_) {
if (discordBot) {
throw new Error('init was already called once');
}
discordBot = discordBot_;
console.log('Activating claimbot');
discordBot.channels.get(channels[0]).send('activating claimbot');
setInterval(announceClaims, 60 * 1000);
announceClaims();
}
function announceClaims() {
let currentBlock = lastProcessedBlock;
getClaimsForLastBlock()
.then(claims => {
claims.forEach(c => {
if (c.height <= lastProcessedBlock) return;
currentBlock = Math.max(currentBlock, c.height);
//filter claims that we don't want to announce
if (c.bid_state === 'Expired' || c.bid_state === 'Spent') return;
discordPost(embedFromClaim(c));
});
lastProcessedBlock = currentBlock;
})
.catch(console.error);
}
/**
*
* @param {Object} claim
* @returns {RichEmbed} discordEmbed
*/
function embedFromClaim(claim) {
let e = new Discord.RichEmbed();
const typeClaim = 1,
typeChannel = 2;
switch (claim.claim_type) {
case typeClaim:
let channelName = claim.channel_name ? claim.channel_name : 'Anonymous';
let channelPermalink = claim.channel_name ? `${claim.channel_name}#${claim.publisher_id}` : '';
let claimPermalink = `${claim.name}#${claim.claim_id}`;
let metadata = JSON.parse(claim.value_as_json).Claim.stream.metadata;
e.setAuthor(`New claim from ${channelName}`, 'http://barkpost-assets.s3.amazonaws.com/wp-content/uploads/2013/11/3dDoge.gif', `https://open.lbry.com/${claimPermalink}`)
.setTitle(`lbry://${claimPermalink}`)
.setURL(`https://open.lbry.com/${claimPermalink}`)
.setColor(1399626)
.setFooter(`Block ${claim.height} • Claim ID ${claim.claim_id} • Data from Chainquery`);
if (metadata.title) e.addField('Title', metadata.title);
if (claim.channel_name) e.addField('Channel', claim.channel_name);
if (metadata.description) {
e.addField('Description', metadata.description.substring(0, 1020));
}
if (metadata.fee) e.addField('Fee', `${metadata.fee.amount} ${metadata.fee.currency}`);
if (metadata.license && metadata.license.length > 2) e.addField('License', metadata.license);
if (!metadata.nsfw && metadata.thumbnail) e.setImage(metadata.thumbnail);
if (claim.bid_state !== 'Controlling' && claim.height < claim.valid_at_height) {
// Claim have not taken over the old claim, send approx time to event.
let blockTime = 150 * 1000;
let takeoverTime = Date.now() + (claim.valid_at_height - claim.height) * blockTime;
e.addField('Takes effect on approx', `${moment(takeoverTime, 'x').format('MMMM Do [at] HH:mm [UTC]')} • at block height ${claim.valid_at_height}`);
}
e.addField('Claimed for', `${Number.parseFloat(claim.bid_amount)} LBC`);
break;
case typeChannel:
e.setAuthor('New channel claim', 'http://barkpost-assets.s3.amazonaws.com/wp-content/uploads/2013/11/3dDoge.gif', `https://open.lbry.com/${claim.name}#${claim.claim_id}`)
.setTitle(`lbry://${claim.name}`)
.setURL(`https://open.lbry.com/${claim.name}#${claim.claim_id}`)
.setColor(1399626)
.setFooter(`Block ${claim.height} • Claim ID ${claim.claim_id} • Data from Chainquery`)
.addField('Channel Name', claim.name);
break;
}
return e;
}
/**
*
* @returns {Promise} claims in last block
*/
function getClaimsForLastBlock() {
return new Promise((resolve, reject) => {
let blockSelectQuery = 'SELECT height FROM block where height > ' + lastProcessedBlock;
if (lastProcessedBlock === 0) {
blockSelectQuery = 'SELECT MAX(height) AS height FROM block';
}
let query =
'SELECT t1.*, t3.name AS channel_name, t4.value AS bid_amount FROM claim t1 INNER JOIN (' +
blockSelectQuery +
') t2 ON t1.height = t2.height ' +
'LEFT JOIN claim t3 ON t1.publisher_id = t3.claim_id LEFT JOIN output t4 ON (t1.transaction_hash_id = t4.transaction_hash AND t1.vout = t4.vout)';
let options = {
method: 'GET',
url: 'https://chainquery.lbry.com/api/sql',
qs: { query: query },
headers: { 'Cache-Control': 'no-cache' }
};
request(options, function(error, response, body) {
if (error) return reject(error);
if (response.statusCode !== 200 || body === null) return reject(response);
try {
body = JSON.parse(body);
} catch (e) {
return reject(e);
}
if (body.success === false || body.error !== null) return reject(body);
let claimsInBlock = body.data;
return resolve(claimsInBlock);
});
});
}
function discordPost(embed) {
channels.forEach(channel => {
discordBot.channels
.get(channel)
.send('', embed)
.catch(console.error);
});
}

View file

@ -16,7 +16,7 @@ function init(discordBot_) {
discordBot = discordBot_;
discordBot.on('message', checkForCommand);
discordBot.on('messageCreate', checkForCommand);
}
/**
@ -35,7 +35,12 @@ let checkForCommand = function(message) {
//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));
try {
//message.channel.send('test1', new Discord.MessageEmbed(commands[command].bundle));
message.channel.send({embeds: [commands[command].bundle]})
} catch (e) {
console.log(e);
}
}
});
if (firstRun) {
@ -47,6 +52,8 @@ let checkForCommand = function(message) {
if (!message.author.bot && message.content.toLowerCase().indexOf('!helpcommands') >= 0) {
let bundle = commands['!helpcommands'].bundle;
bundle.description = '**' + commandsList + '**';
message.channel.send('', new Discord.RichEmbed(bundle));
console.log(bundle);
console.log(bundle.description);
message.channel.send({embeds: [bundle]});
}
};

View file

@ -84,7 +84,7 @@ exports.hash = {
});
let profitcommand = words[0];
let myhashrate = words[1];
if (profitcommand == 'power') {
if (profitcommand === 'power') {
sendProfitInfo(bot, msg, suffix);
return;
} else {
@ -142,7 +142,7 @@ exports.hash = {
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
};
msg.channel.send({ embed });
msg.channel.send({ embeds: [embed] });
return;
});
}
@ -197,7 +197,7 @@ exports.hash = {
icon_url: 'https://spee.ch/6/nKHVQgq.png'
}
};
msg.channel.send({ embed });
msg.channel.send({ embeds: [embed] });
return;
}
});

View file

@ -1,11 +1,11 @@
let inPrivate = require('../helpers.js').inPrivate;
let { RichEmbed } = require('discord.js');
let { MessageEmbed } = require('discord.js');
exports.custom = [
'lbrylink' //change this to your function name
];
exports.lbrylink = async function(bot, msg, suffix) {
bot.on('message', msg => {
bot.on('messageCreate', msg => {
if (inPrivate(msg)) {
return;
}
@ -32,13 +32,13 @@ exports.lbrylink = async function(bot, msg, suffix) {
.replace(/\W+$/g, '')
.replace(/#/g, ':');
}
const linkEmbed = new RichEmbed();
const linkEmbed = new MessageEmbed();
linkEmbed
.setAuthor('LBRY Linker')
.setDescription("I see you tried to post a LBRY URL, here's a friendly link to share and for others to access your content with a single click:")
.setColor(7976557);
urls.forEach(url => linkEmbed.addField('Open with LBRY or LBRY TV:', url, true));
return msg.channel.send({ embed: linkEmbed });
return msg.channel.send({ embeds: [linkEmbed] });
}
});
};

View file

@ -512,7 +512,8 @@ exports.price = {
let currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency;
let amount = words.length > 1 ? parseFloat(words[1], 10) : 1;
let showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1;
let showHelp = !suffix;
//let showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1;
// store the last retrieved rate
let cachedRates = {};
let command = '!price';

View file

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

View file

@ -76,7 +76,10 @@ exports.releasenotes = {
return;
}
if ((hasPerms(msg) && suffix === 'android post') || (hasPerms(msg) && suffix === 'desktop post')) {
bot.channels.get(ChannelID).send(message);
bot.channels
.fetch(ChannelID)
.then(channel => channel.send(message))
.catch(console.error);
} else {
let authorMention = msg.author.toString();
msg.channel.send(`${authorMention}, Release notes sent via DM`);

View file

@ -1,129 +0,0 @@
//let config = require('config');
//let botconfig = config.get('bot');
//let rolelist = config.get('rolelist');
//let inPrivate = require('../helpers.js').inPrivate;
//
//exports.commands = [
// 'addrole', // command that is in this file, every command needs it own export as shown below
// 'delrole',
// 'roles'
//];
//
//exports.addrole = {
// usage: '<role>',
// description: 'Adds you to specified role',
// process: function(bot, msg, suffix) {
// // Provide shortened syntax for the sake of code cleanliness
// let send = msgTxt => msg.channel.send(msgTxt);
// // Checks if the user has messaged the bot via Direct Message
// if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.');
//
// // Here the bot, msg and suffix is avaible, this function can be async if needed.
// // Make sure to eliminate case sensitivity, do this here to only perform the sweep once.
// let newrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase());
// // Baserole is assumed to already be case accurate as it's handled in the config itself.
// let baserole = msg.guild.roles.find(item => item.name === rolelist.baserole);
//
// let rolecmd = botconfig.prefix + 'roles';
//
// // Checks if the user included a role in their message
// if (!suffix) return send('Please specify a role. Type ' + rolecmd + ' to see which you may add yourself!');
// // Checks if there is a matching role found on the server
// if (!newrole) return send('The role specified `' + suffix + '` does not exist on this server!');
// // Checks that the allowed roles and base role against the matched role's name, since this eliminates case sensitivity issues
// if (!rolelist.allowedroles.includes(newrole.name) && !rolelist.baserole.includes(newrole.name)) return send("That role isn't one you can add yourself to! Type " + rolecmd + ' command to find out which ones are allowed.');
// // Use the matched name to check against the member's existing roles
// if (msg.member.roles.find(item => item.name === newrole.name)) return send('It seems you already have the ' + newrole.name + ' role');
//
// // Assuming all these factors succeed, add the role
// msg.member.addRole(newrole).then(send(msg.member + ' has been added to the ' + newrole.name + ' role!'));
//
// // Check if a baserole is actually set
// if (!rolelist.baserole) return;
// // Confirm that the role exists on the server and if not then be sure to send a nag message
// if (!baserole) return send('The base role of ' + rolelist.baserole + ' has been set in config but is missing from the server');
// // Checks if the new role being added is the same as the baserole, then skips the messages below if this is the case.
// if (newrole == baserole) return;
// // Confirm if the user has the baserole already, including if it was added just now
// if (msg.member.roles.find(item => item.name === baserole.name)) return;
// // Add the base role and avoid spamming the user by only mentioning them in the previous message
// msg.member.addRole(baserole).then(send('We also added the base ' + rolelist.baserole + ' role for you!'));
// }
//};
//exports.delrole = {
// usage: '<role>',
// description: 'Deletes the specified role from your account',
// process: function(bot, msg, suffix) {
// // Provide shortened syntax for the sake of code cleanliness
// let send = msgTxt => msg.channel.send(msgTxt);
// // Checks if the user has messaged the bot via Direct Message
// if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.');
// // Here in the bot, msg and suffix are available, this function can be async if needed.
// // Make sure to eliminate case sensitivity, do this here to only perform the sweep once.
// let oldrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase());
// let rolecmd = botconfig.prefix + 'roles';
// // Checks if the user included a role in their message
// if (!suffix) return send('Please specify a role. Type ' + rolecmd + ' to see which you may remove yourself!');
// // Checks if there is a matching role found on the server
// if (!oldrole) return send('The role specified `' + suffix + '` does not exist on this server!');
// // Checks that the allowed roles against the matched role's name, since this eliminates case sensitivity issues
// if (!rolelist.allowedroles.includes(oldrole.name)) return send("That role isn't one you can remove yourself! If you need it removed, please ask a moderator!");
// // Use the matched name to check against the member's existing roles
// if (!msg.member.roles.find(item => item.name === oldrole.name)) return send("It seems you don't actually have the " + oldrole.name + ' role! Mission accomplished!');
//
// // Assuming all these factors succeed, add the role
// msg.member.removeRole(oldrole).then(send(msg.member + ' has been removed from the ' + oldrole.name + ' role!'));
// }
//};
//exports.roles = {
// usage: '',
// description: 'displays roles you can give yourself',
// process: function(bot, msg, suffix) {
// let send = msgTxt => msg.channel.send(msgTxt);
// if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.');
// else {
// // Here in the bot, msg and suffix are available, this function can be async if needed.
// send({
// embed: {
// color: 3447003,
// title: 'Wunderbot',
// description: 'You have accessed the rolebot function of Wunderbot!',
// fields: [
// {
// name: 'List of roles',
// value: buildRoleString(rolelist.allowedroles) + '`' + rolelist.baserole + '`',
// inline: false
// },
// {
// name: 'How to add a role to yourself',
// value: '!addrole (role) - Adds a specified role to yourself.\n!addrole International would add the International role.',
// inline: false
// },
// {
// name: 'How to remove a role from yourself',
// value: '!delrole (role) - Removed a specified role from yourself.\n!delrole International would remove the International role.',
// inline: false
// },
// {
// name: 'NOTE',
// value: 'The LBRY-Curious role will be auto-added when you chose any of the available roles',
// inline: false
// }
// ],
// footer: {
// icon_url: msg.author.avatarURL,
// text: 'Requested by: ' + JSON.stringify(msg.author.username)
// }
// }
// });
// }
// }
//};
//
//function buildRoleString(roles) {
// let str = '';
// for (let i = 0; i < roles.length; i++) {
// str += '`' + roles[i] + '`' + '\n';
// }
// return str;
//}

View file

@ -1,240 +0,0 @@
let request = require('request');
let wget = require('wget');
let config = require('config');
let hasSpeechBotChannels = require('../helpers.js').hasSpeechBotChannels;
let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get('speechbot').mainchannel;
//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
//some have more info on file details of error
let FullDebug = 'true';
//outputs response from speech, very bulk reply
let ResponseDebug = 'false';
exports.commands = [
'speech' // command that is in this file, every command needs it own export as shown below
];
exports.speech = {
usage: '<name>',
description: 'gets top claim from spee.ch, coming soon post to spee.ch',
process: function(bot, msg, suffix) {
if (!hasSpeechBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to speech bot.');
return;
}
let command = '!speech';
words = suffix
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
});
let imagename = words[0];
//check if image name is help, if it is then do help message
if (imagename == 'help') {
doHelp(bot, msg, suffix);
return;
} else {
//check if imagename is defined if not do error
if (imagename === undefined) {
if (FullDebug === 'true') {
let message = '`no name provided`';
console.log('no name provided');
msg.channel.send(message);
doHelp(bot, msg, suffix);
return;
} else {
let message = '`no name provided`';
msg.channel.send(message);
doHelp(bot, msg, suffix);
return;
}
}
//set second word to url
let filepath = words[1];
//check if a url is provided if none do help message
if (filepath === undefined) {
if (FullDebug === 'true') {
let message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
console.log('no url provided');
msg.channel.send(message);
return;
} else {
let message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
msg.channel.send(message);
return;
}
}
//prepare url for other uses
//we will just set filepath to url to be safe
let url = filepath;
//parse first 4 letters of url should be http
let linkvalid = url.slice(0, 4);
//check of url provided begins with http in not throw error and help message
if (linkvalid !== 'http') {
if (FullDebug === 'true') {
let message = '`error not a valid url, please start with http or https`';
console.log('invalid url provided: ' + filepath);
msg.channel.send(message);
return;
} else {
let message = '`error not a valid url, please start with http or https`';
msg.channel.send(message);
return;
}
}
//function to check if url is an image
let isUriImage = function(uri) {
//make sure we remove any nasty GET params
uri = uri.split('?')[0];
//moving on, split the uri into parts that had dots before them
let parts = uri.split('.');
//get the last part ( should be the extension )
let extension = parts[parts.length - 1];
//define some image types to test against
let 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
return imageTypes.indexOf(extension) !== -1;
};
//check if url is an image if its not throw error and help message
if (isUriImage(url) === false) {
if (FullDebug === 'true') {
let message = '`error not a valid image url, be sure the link includes a file type`';
console.log('invalid url provided: ' + url);
msg.channel.send(message);
return;
} else {
let message = '`error not a valid image url, be sure the link includes a file type`';
msg.channel.send(message);
return;
}
}
//set third word to nsfw, with it being an optional functionality
let eighteen = words[2];
//check is NSFW if yes or no sets proper value if none
if (eighteen === '' || eighteen === 'none' || eighteen === undefined || eighteen === null || eighteen === 'no' || eighteen === 'false' || eighteen === false || eighteen === 'n') {
eighteen = 'no';
} else {
eighteen = 'yes';
}
//prepare url for wget
//parse the filename to use to save file
filepath = url.split('/').pop();
//set proper directory for downloading image
let outputFile = 'speech-uploads/' + filepath;
//set download directory to current working directory
let dir = process.cwd();
//set full path to directory for speech uploading
let fullpath = dir + '\\speech-uploads\\' + filepath;
//download url via wget
let download = wget.download(url, outputFile);
//check if url is reachable if not throw error
download.on('error', function(err) {
if (FullDebug === 'true') {
console.log('error could not reach: ' + url + ' : ' + err);
let message = '`error url could not be reached`';
msg.channel.send(message);
} else {
let message = '`error url could not be reached`';
msg.channel.send(message);
}
});
download.on('end', output => {
//if no errors and file ready -> do the request
output && doSteps(bot, imagename, url, eighteen);
});
}
//send help message
function doHelp(bot, msg, suffix) {
msg.channel.send({
embed: {
title: '',
description:
'**!speech `<Name>`** : *displays top claim on speech* \n\n\n' +
'**COMING SOON POSTING TO SPEECH** \n\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' +
'EXAMPLE : `!speech my-image-name https://url/to/image.png false`',
color: 7976557,
author: {
name: 'Speech Bot Help',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
});
}
//send post request to speech
function doSteps(bot, imagename, url, eighteen) {
request.post(
//url to send post request
'https://spee.ch/api/publish',
//json payload
{
json: {
name: imagename,
file: fullpath,
nsfw: eighteen
}
},
//get response from server
function(error, response, body) {
//output response if ResponseDebug set to true
if (ResponseDebug === 'true') {
console.log(response);
console.log(error);
console.log(body.success);
console.log(body.message);
}
//check speech response for file path error, if found throw internal error!
if (body.message === 'no files found in request') {
if (FullDebug === 'true') {
console.log('no file found: ' + fullpath);
let message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
} else {
let message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
}
}
//check speech response for filename error, if found throw internal error!
if (body.message === 'no name field found in request') {
if (FullDebug === 'true') {
console.log('no name field found: ' + imagename);
let message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
} else {
let message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
}
}
//if no errors post this message
let message = 'uploading... \n "name":"' + 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);
}
);
}
}
};

View file

@ -75,7 +75,7 @@ exports.stats = {
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
};
msg.channel.send({ embed });
msg.channel.send({ embeds: [embed] });
}
});
}

View file

@ -1,32 +0,0 @@
'use strict';
let initialized = false;
let discordBot = 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) {
//if the close command is found
if (!message.author.bot && message.content.toLowerCase().indexOf('!close') >= 0) {
//send the -close command twice with a 4 seconds timeout
message.channel.send('-close').catch(console.error);
setTimeout(() => {
message.channel.send('-close').catch(console.error);
}, 4000);
}
};

View file

@ -1,283 +0,0 @@
let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require('../helpers.js').inPrivate;
/* Disabled Temporarily
exports.custom = ['onUserJoin'];
exports.onUserJoin = function(bot) {
bot.on('guildMemberAdd', member => {
member
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
'**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' +
'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 Approval*? Please make a request in the #rewards-approval channel by sending a direct message (DM) to @RewardsBot#0287. You can do this by right clicking on the name. A mod will reach out to you, please be patient . **Note: DO NOT message any team members or post in other channels about rewards approval concerns.**. Only 1 Reward account is allowed per household** \n',
url: 'https://lbry.com/what',
color: 7976557,
author: {
name: 'Welcome to LBRY Discord Community',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
bot.channels
.get('369896313082478594')
.send(
member +
', Please enable Direct Messages from server members to communicate fully with our bot, it is located in the user setting area under Privacy & Safety tab, select the option allow direct messages from server members\nSince the bot could not send you our Welcome message please check the posts in <#431211007050776577> and see the Wunderbot and tipbot commands by typing `!help` in <#369896313082478594>'
);
});
member
.send({
embed: {
description:
'1. Be respectful to other community members. Harassment and vulgarity will not be tolerated \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' +
'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' +
'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',
color: 7976557,
author: {
name: 'Ground rules',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
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' +
'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 responsibility, see FAQ link below \n' +
'4. You can find the LBRY Block explorer at https://explorer.lbry.com \n' +
'5. Want to contribute more? Check out https://lbry.tech/contribute \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',
color: 7976557,
author: {
name: 'Helpful hints',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
'[**LBRY**](https://lbry.com) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.com/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.com/get)',
url: 'https://lbry.com/what',
color: 7976557,
author: {
name: 'What is LBRY?',
url: 'https://lbry.com/what',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description:
'Want to backup your LBRY wallet? [**Backup**](https://lbry.com/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.com/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.com/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.com/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troubleshoot streaming**](https://lbry.com/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.com/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.com/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.com/faq/referrals)',
url: 'https://lbry.com/faq',
color: 7976557,
author: {
name: 'LBRY FAQ',
url: 'https://lbry.com/faq',
icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
title: '*Have you checked out spee.ch yet?!*',
description:
"[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistant 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 retrieve 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',
color: 7976557,
author: {
name: 'spee.ch',
url: 'https://spee.ch',
icon_url: 'https://spee.ch/e/flag-green-blue-purple-indigo-bars-background.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
console.log(error);
});
});
};
*/
exports.commands = [
'welcome' // command that is in this file, every command needs it own export as shown below
];
exports.welcome = {
usage: '<@username>',
description: 'send welcome message to specified user',
process: function(bot, msg, suffix) {
if (inPrivate(msg)) {
msg.channel.send('command cannot be used in a DM');
return;
}
if (suffix === '') {
msg.channel.send('no user defined');
return;
}
if (!hasPerms(msg)) {
msg.channel.send('You Dont Have Permission To Use This Command!');
return;
}
msg.mentions.members
.first()
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
'**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' +
'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 Approval*? Please make a request in the #rewards-approval channel by sending a direct message (DM) to @RewardsBot#0287. You can do this by right clicking on the name. A mod will reach out to you, please be patient, **Note: DO NOT message any team members or post in other channels about rewards approval concerns.**. Only 1 Reward account is allowed per household** \n',
url: 'https://lbry.com/what',
color: 7976557,
author: {
name: 'Welcome to LBRY Discord Community',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
msg.channel.send(
msg.mentions.members.first() +
', Please enable Direct Messages from server members to communicate fully with our bot, it is located in the user setting area under Privacy & Safety tab, select the option allow direct messages from server members'
);
});
msg.mentions.members
.first()
.send({
embed: {
description:
'1. Be respectful to other community members. Harassment and vulgarity will not be tolerated \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' +
'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' +
'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',
color: 7976557,
author: {
name: 'Ground rules',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
console.log(error);
});
msg.mentions.members
.first()
.send({
embed: {
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' +
'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 responsibility, see FAQ link below \n' +
'4. You can find the LBRY Block explorer at https://explorer.lbry.com \n' +
'5. Want to contribute more? Check out https://lbry.com/faq/contributing \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',
color: 7976557,
author: {
name: 'Helpful hints',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
console.log(error);
});
msg.mentions.members
.first()
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
'[**LBRY**](https://lbry.com) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.com/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.com/get)',
url: 'https://lbry.com/what',
color: 7976557,
author: {
name: 'What is LBRY?',
url: 'https://lbry.com/what',
icon_url: 'https://spee.ch/2/pinkylbryheart.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
console.log(error);
});
msg.mentions.members
.first()
.send({
embed: {
title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description:
'Want to backup your LBRY wallet? [**Backup**](https://lbry.com/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.com/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.com/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.com/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troubleshoot streaming**](https://lbry.com/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.com/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.com/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.com/faq/referrals)',
url: 'https://lbry.com/faq',
color: 7976557,
author: {
name: 'LBRY FAQ',
url: 'https://lbry.com/faq',
icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
}
}
})
.catch(console.error)
console.log('could not send dm');
console.log(error);
msg.mentions.members
.first()
.send({
embed: {
title: '*Have you checked out spee.ch yet?!*',
description:
"[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistant 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 retrieve 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',
color: 7976557,
author: {
name: 'spee.ch',
url: 'https://spee.ch',
icon_url: 'https://spee.ch/e/flag-green-blue-purple-indigo-bars-background.png'
}
}
})
.catch(function(error) {
console.log('could not send dm');
console.log(error);
});
}
};

2389
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,21 +1,21 @@
{
"dependencies": {
"app-root-path": "^2.2.1",
"app-root-path": "^3.0.0",
"braces": "^3.0.2",
"chrono-node": "^2.2.4",
"config": "^3.3.1",
"discord.js": "^12.5.3",
"chrono-node": "^2.3.1",
"config": "^3.3.6",
"discord.js": "^13.1.0",
"file-exists": "^5.0.1",
"jsonfile": "^5.0.0",
"jsonpath": "^1.0.1",
"moment": "^2.26.0",
"mongodb": "^3.5.8",
"mongoose": "^5.12.3",
"needle": "^2.5.0",
"jsonfile": "^6.1.0",
"jsonpath": "^1.1.1",
"moment": "^2.29.1",
"mongodb": "^4.1.1",
"mongoose": "^6.0.5",
"needle": "^3.0.0",
"numeral": "^2.0.6",
"request": "^2.88.2",
"request-promise": "^4.2.5",
"sleep": "^6.2.0",
"request-promise": "^4.2.6",
"sleep": "^6.3.0",
"wget": "^0.0.1"
},
"scripts": {
@ -28,7 +28,7 @@
"prettier": "^1.19.1"
},
"name": "wunderbot-discord",
"version": "1.0.6",
"version": "1.0.7",
"description": "LBRY bot for Discord",
"main": "bot/bot.js",
"repository": "https://github.com/lbryio/lbry-wunderbot",