Commit 2cdd25fd authored by insert's avatar insert

Pushing old version of v3

parent f9796313
token.json
node_modules
\ No newline at end of file
const Discord = needs('discord');
const core = needs('core');
let common = core.common('booru');
const sites = common.booru.sites;
const process = common.process;
module.exports = (msg, args) => {
if (args.length < 1) {
var embed = new Discord.RichEmbed();
embed.setTitle('booru');
embed.setDescription('74 uses the npm booru module, below is the usage, available sites and commands.\nThe available sites are queried from the module itself.');
embed.addField('sites', Object.keys(sites), true);
embed.addField('usage', [';booru <site> [tags]', ';commands booru'], true);
return msg.channel.send({
embed
});
}
var s = args.shift();
process(msg, s, args);
};
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'danbooru', args);
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'e621', args);
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'e926', args);
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'gelbooru', args);
\ No newline at end of file
const booru = require('booru');
let search = (site, tags, cb) => {
if (site == 'lb' || site.includes('loli') || /loli|shota/g.test(tags.join(' '))) return cb((Math.random() * 2) > 1 ? 'haha no, read Discord ToS' : 'no jail for you :triumph: :triumph: :triumph:');
booru.search(site, tags, {
limit: 1,
random: true
})
.then(booru.commonfy)
.then(images => {
for (let image of images) {
cb(image.common.file_url)
}
})
.catch(err => {
if (err.name === 'booruError') {
if (err.message.includes('give any images')) cb('', 'Couldn\'t find any images!');
else cb('', err.message)
} else {
cb('', err)
}
});
};
module.exports = {
common: {
booru,
search,
process: (msg, site, args) => {
if ((() => {
nsfl = false;
Object.keys(booru.sites).forEach(x => {
var s = booru.sites[x];
s.aliases.forEach(y => {
if (y == site) {
if (s.nsfw) nsfl = true;
}
});
});
return nsfl
})() && !msg.channel.nsfw) return msg.reply('this is not a nsfw channel!');
search(site, args, (image, err) => {
if (err) return msg.reply(`error occurred! [${err}]`);
msg.channel.send(image);
});
}
}
};
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'rule34', args);
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'safebooru', args);
\ No newline at end of file
const core = needs('core');
const process = core.common('booru').process;
module.exports = (msg, args) => process(msg, 'yandere', args);
\ No newline at end of file
module.exports = {
desc: 'A set of tools to search up information',
commands: {
whats: 'Help command for dictionary',
oxford: 'Lookup a word on Oxford',
wikipedia: 'Lookup a query on Wikipedia',
urban: 'Look up a word on UD',
ud: 'Look up serveral answers for a word on UD'
},
common: {
oxford_key: {
app_id: 'e871a8b4',
api_key: 'b5c1edbdec918939f585d72cd59c1e8d'
}
}
};
\ No newline at end of file
const Discord = needs('discord');
const core = needs('core');
const request = needs('libs').req;
const oxford_key = core.common('dictionary').oxford_key;
let oxford = (q, cb) => {
request({
url: `https://od-api.oxforddictionaries.com/api/v1/entries/en/${q}`,
headers: {
'app_id': oxford_key.app_id,
'app_key': oxford_key.api_key
}
}, (err, res, body) => {
if (err) cb(false);
try {
var data = JSON.parse(body);
cb(data.results[0].lexicalEntries);
} catch (err) {
cb(false);
}
});
};
module.exports = (msg, args) => {
if (args.length < 1) return msg.reply('please specify a query!');
oxford(args.join(' ').replace(/ /g, '+'), function (data) {
if (data == false) return msg.reply('found nothing! Try another dictionary, `;whats`');
var embed = new Discord.RichEmbed();
embed.setTitle('Oxford dictionary - ' + args.join(' '));
for (var i = 0; i < data.length && i < 3; i++) {
var def = data[i];
var ent = def.entries[0];
var t = ['```markdown',
'> gramatical features',
'# text: ' + ent.grammaticalFeatures[0].text,
'# type: ' + ent.grammaticalFeatures[0].type,
'```'
];
if (!(typeof ent.etymologies === 'undefined')) {
t.push('```markdown');
t.push('> etymologies:');
for (var i = 0; i < ent.etymologies.length; i++) t.push('# ' + ent.etymologies[i]);
t.push('```');
}
if (!(typeof ent.senses === 'undefined') && !(typeof ent.senses[0].definitions === 'undefined')) {
t.push('```markdown');
t.push('> senses - definitions:');
for (var i = 0; i < ent.senses[0].definitions.length; i++) t.push('# ' + ent.senses[0].definitions[i]);
t.push('```');
}
if (!(typeof ent.senses === 'undefined') && !(typeof ent.senses[0].examples === 'undefined')) {
t.push('```markdown');
t.push('> senses - examples:');
for (var i = 0; i < ent.senses[0].examples.length; i++) t.push('# ' + ent.senses[0].examples[i].text);
t.push('```');
}
embed.addField(def.text, t);
}
msg.channel.send({
embed
});
});
};
\ No newline at end of file
const Discord = needs('discord');
const request = needs('libs').req;
let urban = (q, cb) => {
request(`http://api.urbandictionary.com/v0/define?page=1&term=${q}`, (err, res, body) => {
if (err) return cb(false);
var data = JSON.parse(body);
if (data.result_type == 'no_results') return cb(false);
cb(data.list);
});
};
module.exports = (msg, args) => {
if (args.length < 1) return msg.reply('please specify a query!');
urban(args.join(' '), function (data) {
if (data == false) return msg.reply('found nothing! Try another dictionary, `;whats`');
var embed = new Discord.RichEmbed();
embed.setTitle('urbandictionary - ' + args.join(' '));
for (var i = 0; i < data.length && i < 3; i++) {
var def = data[i];
if (def.definition.length > 100) {
def.definition = def.definition.substring(0, 100);
def.definition += ' [read more on Urban]';
}
if (def.example.length > 100) {
def.example = def.example.substring(0, 100);
def.example += ' [read more on Urban]';
}
embed.addField(def.word, ['[Definition:](' + def.permalink + ')', '```', def.definition, '```', 'Example:', '```', def.example, '```']);
}
msg.channel.send({
embed
});
});
};
\ No newline at end of file
const Discord = needs('discord');
const request = needs('libs').req;
let urban = (q, cb) => {
request(`http://api.urbandictionary.com/v0/define?page=1&term=${q}`, (err, res, body) => {
if (err) return cb(false);
var data = JSON.parse(body);
if (data.result_type == 'no_results') return cb(false);
cb(data.list);
});
};
module.exports = (msg, args) => {
if (args.length < 1) return msg.reply('please specify a query!');
urban(args.join(' '), function (data) {
if (data == false) return msg.reply('found nothing! Try another dictionary, `;whats`');
var embed = new Discord.RichEmbed();
embed.setTitle('urbandictionary - ' + args.join(' '));
var def = data[0];
if (def.definition.length > 440) {
def.definition = def.definition.substring(0, 440);
def.definition += ' [read more on Urban]';
}
if (def.example.length > 440) {
def.example = def.example.substring(0, 440);
def.example += ' [read more on Urban]';
}
embed.addField(def.word, ['[Definition:](' + def.permalink + ')', '```', def.definition, '```', 'Example:', '```', def.example, '```']);
msg.channel.send({
embed
});
});
};
\ No newline at end of file
const Discord = needs('discord');
module.exports = (msg, args) => {
var embed = new Discord.RichEmbed();
embed.setTitle(':books: Word Lookup');
embed.setDescription('Supports Urban, Oxford [beta] and Wikipedia [alpha]');
embed.addField('usage', [';urban [QUERY] - quick lookup', ';ud [QUERY] - full lookup', ';oxford [QUERY] - lookup on Oxford Dictionary', ';wikipedia [QUERY] - look up on Wikipedia [alpha]'], false);
msg.channel.send({
embed
});
};
\ No newline at end of file
const Discord = needs('discord');
const request = needs('libs').req;
let wikipedia = (q, cb) => {
request(`https://wikipedia.org/w/api.php?action=query&format=json&prop=revisions&meta=siteinfo&continue=&titles=${q.replace(/ /g,'+')}&rvprop=content`, (err, res, body) => {
var data = JSON.parse(body);
var p = data.query.pages;
if (Object.keys(p).length < 1) return cb(false);
var page = p[Object.keys(p)[0]];
if (typeof page.revisions === 'undefined') return cb(false);
var rev = page.revisions[0]['*'];
var info = rev.replace(/<[^>]*>|{[^}]*}|\\n|[\n]|\|[^|]*\||'[^']*'|[}{\]\[*]/g, '');
cb({
info: info,
title: page.title
});
});
};
module.exports = (msg, args) => {
if (args.length < 1) return msg.reply('please specify a query!');
wikipedia(args.join(' '), function (data) {
if (data == false) return msg.reply('found nothing! Try another dictionary, `;whats`');
var embed = new Discord.RichEmbed();
embed.setTitle('Wikipedia - ' + data.title);
if (data.info.length > 900) data.info = data.info.substring(0, 900) + ' [read more on Wikipedia]';
embed.setDescription([`[${data.title}](https://en.wikipedia.org/wiki/${data.title})`,
data.info
]);
msg.channel.send({
embed
});
});
};
\ No newline at end of file
module.exports = (msg, args) => {
};
\ No newline at end of file
let Fortnite = require('fortnite-api');
let fortniteAPI = new Fortnite([
"[email protected]",
"kerchow74",
"MzRhMDJjZjhmNDQxNGUyOWIxNTkyMTg3NmRhMzZmOWE6ZGFhZmJjY2M3Mzc3NDUwMzlkZmZlNTNkOTRmYzc2Y2Y=",
"ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ="
], {
debug: true
});
let connected = false;
let get = (username, platform) => {
return fortniteAPI.getStatsBR(username, platform);
};
module.exports = {
desc: 'Fortnite BR Stats',
common: {
get: (username, platform) => {
return new Promise((resolve, reject) => {
if (!connected) {
fortniteAPI.login().then(() => {
connected = true;
get(username, platform).then(resolve).catch(() => reject(false));
}).catch(e => {
reject("Couldn't login to Fortnite!");
});
}
get(username, platform).then(resolve).catch(() => reject(false));
});
}
}
};
\ No newline at end of file
const fs = require('fs');
var modules = {};
var commands = {};
const permissions = needs('services').permissions;
let core = {
reload: () => {},
process: (msg, cmd, args) => {
if (commands[cmd]) {
let perm = permissions(msg.author, msg.member);
if (perm >= commands[cmd].req) commands[cmd].func(msg, args);
else msg.reply(`permission level too low! [${perm} not ${commands[cmd].req}]`);
}
},
common: mod => {
return modules[mod].common;
},
all: () => {
return commands;
},
mods: () => {
return modules;
}
};
module.exports = core;
components.core = core;
let nrc = mod => {
try {
delete require.cache[require.resolve(mod)];
} catch (e) {}
};
let index = path => {
path += 'index.js';
let o = {};
if (fs.existsSync(path)) {
nrc(path);
o = require(path.replace(/core\//g, ''));
}
return Object.assign({
desc: 'No description.',
disabled: [],
commands: {},
common: {}
}, o);
};
core.reload = () => {
commands = {};
modules = {};
let mods = fs.readdirSync('./core');
mods.forEach(mod => {
if (mod == 'index.js') return;
let path = `./core/${mod}/`;
let cmds = fs.readdirSync(path);
let i = index(path);
modules[mod] = i;
cmds.forEach(cmd => {
if (cmd == 'index.js' || cmd == 'lib') return;
if (cmd in i.disabled) return;
let a = (path + cmd).replace(/core\//g, '');
nrc(a);
let m = require(a);
let n = cmd.split('.').shift();
if (commands[n]) console.log('[WARN] A conflict has been detected, command ' + n + ' already exists! And ' + mod + ' is now overwriting it!');
let util = require('util');
if (!i.commands[n]) i.commands[n] = {};
commands[n] = Object.assign({
func: m,
desc: 'No description!',
req: 0
}, i.commands[n]);
});
});
};
core.reload();
\ No newline at end of file
This diff is collapsed.
module.exports = {
desc: 'uhhh',
commands: {
beemovie: 'The full beemovie script'
}
};
\ No newline at end of file
module.exports = {
desc: 'Access to npm',
commands: {
npm: {
desc: 'Direct access to npm',
req: 3
}
},
common: {
npmi: require('npmi')
}
};
\ No newline at end of file
const Discord = needs('discord');
const core = needs('core');
const { npmi } = core.common('npm');
module.exports = (msg, args) => {
switch (args.shift()) {
case 'install':
if (args.length<1) return msg.reply('not enough arguments!');
var options = {
name: args.shift()
};
try {
npmi(options, function (err, result) {
if (err) {
if (err.code === npmi.LOAD_ERR) return msg.reply('npm load error, `'+err.message+'`');
else if (err.code === npmi.INSTALL_ERR) return msg.reply('npm install error, `'+err.message+'`');
}
msg.reply('successfully installed `'+options.name+'`!');
console.log('npmModuleInstalled','installed `'+options.name+'`');
});
} catch (err) {
return msg.reply('npmi error, `'+err.message+'`');
}
break;
default:
var embed = new Discord.RichEmbed();
embed.setTitle('npm');
embed.setDescription('Install npm packages directly from the bot.');
embed.addField('usage',';npm install [PACKAGE]',true);
embed.addField('npm','using '+npmi.NPM_VERSION,true);
msg.channel.send({embed});
break;
}
};
\ No newline at end of file
module.exports = {
desc: 'Reddit interface',
commands: {
reddit: {
desc: 'Chat-based Reddit "browser"'
}
},
common: {
req: require('request')
}
};
\ No newline at end of file
const Discord = needs('discord');
const request = needs('libs').req;
let reddit = {
subreddit: (subreddit, callback) => {
request('https://www.reddit.com/r/' + subreddit + '.json', (err, res, body) => {
if (err) return callback(false);
var data = JSON.parse(body);
var ret = [];
if (typeof data.data === 'undefined') return callback(false);
if (data.data.children.length < 1) return callback(false);
for (var i = 0; i < data.data.children.length; i++) {
var c = data.data.children[i];
var a = {
self: c.data.is_self,
author: c.data.author,
nsfw: c.data.over_18,
subreddit: c.data.subreddit,
url: 'https://www.reddit.com' + c.data.permalink,
title: c.data.title,
upvotes: c.data.ups
};
if (c.data.is_self) {
a.text = c.data.selftext;
} else {
a.src = c.data.url;
}
ret.push(a);
}
callback(ret);
});
}
};
module.exports = (msg, args) => {
if (args.length < 1) return msg.reply('usage: `;reddit <subreddit> [post]`');
var embed = new Discord.RichEmbed();
reddit.subreddit(args.shift(), function (data) {
if (data == false) return msg.reply('can\'t find any posts!');
var post = data[Math.floor(Math.random() * data.length)];
if (post.nsfw && !msg.channel.nsfw) return msg.reply('cannot send nsfw post!');
var p = '';
post.nsfw ? p = '[NSFW] ' : p = '';
embed.setTitle(p + 'Post retrieved from `' + post.subreddit + '`');
embed.setDescription('[' + post.title + '](' + post.url + ')\n' + post.upvotes + ' upvotes');
if (post.self) {
embed.addField('selfpost', ['```' + post.text.substring(0, 800) + '```'], true);
} else {
embed.setImage(post.src);
}
msg.channel.send({
embed
});
});
};
\ No newline at end of file
const Discord = needs('discord');
const core = needs('core');
module.exports = (msg, args) => {
let embed = new Discord.RichEmbed();
embed.setTitle('commands');
let a = args.shift();
let modules = core.mods();
let commands = core.all();
switch (a) {
case 'cat':
embed.setDescription('To view a category of commands do `;commands cat <name>`\n**dosen\'t work yet!**');
break;
case '*':
embed.setDescription(Object.keys(commands).join(' · '));
break;
default:
let r = parseInt(a);
let c = Object.keys(commands);
if (isNaN(r)) {
r = 1;
if (!modules[a]) {
embed.setDescription(['See categories: `;commands cat`',
'See all commands: `;commands *`',
'See modules: `;modules`']);
} else {
embed.setDescription(`Commands for ${a}`);
let copy = {};
c = Object.keys(modules[a].commands);
c.forEach(v => {
copy[v] = commands[v];
});
commands = copy;
let b = args.shift();
if (b) {
let t = parseInt(b);
if (!isNaN(t)) {
r = t;
}
}
}
}
let max = Math.ceil(c.length / 10);
if (r < 1) r = 1;
if (r > max) r = max;
let f = [];
r -= 1;
c.forEach((v, i) => {
if (!(i >= r * 10 && i < r * 10 + 10)) return;
f.push(`**;${v}** - ${commands[v].desc}`);
});
embed.setFooter(`Page ${r + 1} / ${max} - \`;commands [page]\``);
embed.addField('cmds', f.length == 0 ? 'No commands!' : f);
break;
}
msg.channel.send({embed});
};
\ No newline at end of file
const core = needs('core');
module.exports = (msg, args) => {
if (args.length < 1) return msg.reply('usage: `;disable <module>`');
let m = args.shift();
let mods = core.mods();
let commands = core.all();
if (mods[m]) {
Object.keys(mods[m].commands).forEach(v => {
delete commands[v];
});
msg.reply('disabled module!');
} else {
msg.reply('module does not exist!');
}
};
\ No newline at end of file
const client = needs('client');
const Discord = needs('discord');
const util = require('util');
module.exports = (msg, args) => {
var embed = new Discord.RichEmbed();
var i = args.join(' ');
embed.setTitle('eval');
embed.addField('input', ['```', i + '```'], true);
embed.addBlankField(true);
try {
embed.addField('output', ['```js', util.inspect(eval(i), false, 1).substring(0, 1000).replace(new RegExp(client.token, 'g'), '') + '```'], true);
} catch (e) {
embed.addField('error', ['```js', util.inspect(e, false, 1).substring(0, 1000).replace(new RegExp(client.token, 'g'), '').replace(new RegExp(__dirname, 'g'), '/path/to/74') + '```'], true);
}
msg.channel.send({
embed
});
};
\ No newline at end of file
const { exec } = require('child_process');
module.exports = (msg, args) => {
var e = args.join(' ');
if (e.length<1) return msg.reply('empty exec, cannot run!');
try {
exec(e, (err, stdout, stderr) => {
if (err) return msg.channel.send(['```js',err,'```']);
msg.channel.send(['```js',stdout.toString(),'```']);
});
} catch (err) {
msg.reply('`'+err+'`');
}
};
\ No newline at end of file
const Discord = needs('discord');
module.exports = msg => {
let embed = new Discord.RichEmbed();