Skip to content

Commit

Permalink
Merge pull request #40 from muricans/mbot-testing
Browse files Browse the repository at this point in the history
7.6.2
  • Loading branch information
muricans authored Jun 10, 2019
2 parents b7d18ea + 9655b62 commit aef7957
Show file tree
Hide file tree
Showing 9 changed files with 507 additions and 172 deletions.
60 changes: 54 additions & 6 deletions commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module.exports.registerCommands = async (client, mbot) => {
const mod = require(`./commands/mod/${file}`);
client.commands.set(mod.name, mod);
}
client.commands.set('meme', {
name: 'meme',
description: 'Gets a random meme',
});

mbot.event.emit('filesLoaded');

Expand All @@ -66,6 +70,50 @@ module.exports.registerCommands = async (client, mbot) => {
'ass', 'anal', 'uptime',
];

const nCmds = [];

nCmds.push({
name: 'anal',
}, {
name: 'trap',
}, {
name: 'thighs',
}, {
name: 'rule34',
}, {
name: 'pegging',
}, {
name: 'nsfw',
}, {
name: 'hentai',
}, {
name: 'hardcore',
}, {
name: 'ass',
}, {
name: 'gay',
}, {
name: 'dick',
}, {
name: 'boobs',
}, {
name: 'blowjob',
});

for (let i = 0; i < nCmds.length; i++) {
const description = `Gets a random ${nCmds[i].name} image`;
nCmds[i].description = description;
}

const nsfwcmds = client.commands.array().filter(cmd => cmd.nsfw === true);
for (let i = 0; i < nsfwcmds.length; i++) {
nCmds.push({
name: nsfwcmds[i].name,
description: nsfwcmds[i].description,
});
}
nCmds.sort((a, b) => (a.name > b.name) ? 1 : -1);

function handleOther(command, message, args) {
if (command === 'test') {
message.channel.send("Test recieved").then(async sent => {
Expand Down Expand Up @@ -190,7 +238,7 @@ module.exports.registerCommands = async (client, mbot) => {
}
}

function doCommand(comm, message, prefix, args) {
function doCommand(comm, message, prefix, args, n) {
if (comm.args) {
if (args.length < comm.minArgs) {
return message.channel.send(`${message.author} Please add params! ${prefix}${comm.name} ${comm.usage}`);
Expand All @@ -199,7 +247,7 @@ module.exports.registerCommands = async (client, mbot) => {
const isOwner = bot_owners_id.find(id => id === message.author.id);
if (isOwner) {
try {
return comm.execute(message, args, client, prefix);
return comm.execute(message, args, client, prefix, n);
} catch (err) {
console.log(err);
}
Expand All @@ -223,7 +271,7 @@ module.exports.registerCommands = async (client, mbot) => {
return message.channel.send(`${message.author} Please wait ${left.toFixed(1)} second(s) before running that command again!`);
}
}
comm.execute(message, args, client, prefix);
comm.execute(message, args, client, prefix, n);
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldown);
} catch (err) {
Expand Down Expand Up @@ -339,15 +387,15 @@ module.exports.registerCommands = async (client, mbot) => {
if (message.author.id != owner) {
return message.channel.send(`${message.author} You don't have permission to use this command!`);
} else {
return doCommand(comm, message, prefix, args);
return doCommand(comm, message, prefix, args, nCmds);
}
}
});
} else if (comm.mod) {
if (message.author.id === client.user.id) return;
return doCommand(comm, message, prefix, args);
return doCommand(comm, message, prefix, args, nCmds);
} else {
return doCommand(comm, message, prefix, args);
return doCommand(comm, message, prefix, args, nCmds);
}
});
});
Expand Down
1 change: 1 addition & 0 deletions commands/danbooru.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
name: 'danbooru',
usage: '[tags]',
description: 'Returns a danbooru image [NSFW Available]',
nsfw: true,
execute(message, args) {
message.delete(1000);
if (args.length === 0) {
Expand Down
223 changes: 94 additions & 129 deletions commands/help.js
Original file line number Diff line number Diff line change
@@ -1,144 +1,109 @@
const Discord = require('discord.js');
const EmbedBuilder = require('../embedbuilder');

// 17 commands + [5 admin only commands] + 14 nsfw commands
// seperate admin only commands at a later time
const min = 1;
const max = 6;

function pageOne(edit, message, prefix) {
const embed = new Discord.RichEmbed()
.setTitle('Commands')
.addField(prefix + '8ball <question>', 'Ask the bot a question')
.addField(prefix + 'article [category]', 'Returns a random article with specified category if one is provided.')
.addField(prefix + 'ban <user> [reason]', 'Bans specified user.')
.addField(prefix + 'create <commandName> <message>', 'Adds a command to the bot')
.addField(prefix + 'clean <user> [messageAmount]', 'Deletes a specified amount of messages for a user [admin only]')
.addField(prefix + 'danbooru [tags]', 'Returns a danbooru image [NSFW Available]')
.addField(prefix + 'delete <commandName>', 'Deletes a command [added by !create] from the bot [admin only]')
.addField(prefix + 'echo <message>', 'Returns your message from the bot [admin only]')
.setFooter('Page (1/' + max + ')');
if (edit) {
return message.edit(embed);
} else if (!edit) {
return message.channel.send(embed);
}
}

module.exports = {
name: 'help',
usage: '[command]',
description: 'Gives you a list of help commands, or info on a specified command.',
cooldown: 3,
execute(message, args, client, prefix) {
if (args.length === 0) {
let page = 1;
pageOne(false, message, prefix).then(async sent => {
await sent.react("◀");
await sent.react("▶");
sent.awaitReactions((reaction, user) => {
if (user.id != client.user.id) {
if (reaction.emoji.name === "◀") {
reaction.remove(user);
page--;
} else if (reaction.emoji.name === "▶") {
reaction.remove(user);
page++;
}

const pageData = 'Page (' + page + '/' + max + ')';
let embed;

switch (page) {
case 1:
pageOne(true, sent, prefix);
break;
case 2:
embed = new Discord.RichEmbed()
.setTitle('Commands')
.addField(prefix + 'give <user> <points>', 'Gives a user [x] amount of points')
.addField(prefix + 'help [command]', 'Returns a list of commands for this bot')
.addField(prefix + 'imgur [hash]', 'Returns a random image from imgur, or an image with the provided hash')
.addField(prefix + 'kick <user> [reason]', 'Kicks specified user')
.addField(prefix + 'leaderboard', 'Get up to 50 users with the most points')
.addField(prefix + 'meme', 'Returns a random meme')
.addField(prefix + 'modules <moduleName> <moduleOption> [setTo, ?name] [?setTo]', 'Use modules for your server. [Documentation](https://muricans.github.io/mbot/)')
.addField(prefix + `mute <user> <time?'min','hour'>`, `Keeps a player from chatting for specified time.`)
.setFooter(pageData);
sent.edit(embed);
break;
case 3:
embed = new Discord.RichEmbed()
.setTitle('Commands')
.addField(prefix + 'ping', 'Returns pong')
.addField(prefix + 'prefix <newPrefix>', 'Changes the bots prefix [admin only]')
.addField(prefix + 'points [user]', "Returns the designated user's (or your own) points")
.addField(prefix + 'qr <information>', 'Returns a QR code with the designated information')
.addField(prefix + 'random <subreddit> [time|search] [search]', 'Returns a random thread from a subreddit')
.addField(prefix + 'roulette <amount>', 'Returns win/loss and new total points')
.addField(prefix + 'roll [number]', 'Returns a random number between 1 and the chosen number')
.addField(prefix + 'serverinfo [serverID]', 'Get server info on the server you are currently on, or another the bot is currently on by giving that servers ID.')
.setFooter(pageData);
sent.edit(embed);
break;
case 4:
embed = new Discord.RichEmbed()
.setTitle('Commands')
.addField(prefix + 'set <user> <points>', 'Sets the users points [admin only]')
.addField(prefix + 'suggest <suggestion>', 'Suggest a command or feature for the bot')
.addField(prefix + 'suggestions [clear]', 'Check the suggestions, (include <clear> [admin only] to clear the suggestions)')
.addField(prefix + `timer <time?'min','hour'|cancel|list> [name]`, 'Set a timer for the bot to remind you on when it completes.')
.addField(prefix + 'unmute <user>', 'Unmute a muted user')
.addField(prefix + 'userinfo [user]', "Returns the designated user's info")
.addField(prefix + 'version', 'Returns the bot version and information')
.addField('NSFW Commands on Page 5+6', '🔞')
.setFooter(pageData);
sent.edit(embed);
break;
case 5:
embed = new Discord.RichEmbed()
.setTitle('NSFW Commands')
.addField(prefix + 'anal', 'Returns an anal image')
.addField(prefix + 'ass', 'Returns an image of an ass')
.addField(prefix + 'blowjob', 'Returns a blowjob image')
.addField(prefix + 'boobs', 'Returns a picture of a pair of milkers')
.addField(prefix + 'dick', 'Returns an image of a dick')
.addField(prefix + 'gay', 'Returns a gay porn image')
.addField(prefix + 'hardcore', 'Returns a hardcore porn image')
.setFooter(pageData);
sent.edit(embed);
break;
case 6:
embed = new Discord.RichEmbed()
.setTitle('NSFW Commands')
.addField(prefix + 'hentai', 'Returns a hentai image')
.addField(prefix + 'nsfw', 'Returns an nsfw image (Straight)')
.addField(prefix + 'pegging', 'Returns a pegging image')
.addField(prefix + 'r34xxx [tags]', 'Returns an image from rule34')
.addField(prefix + 'rule34', 'Returns a rule34 image from reddit')
.addField(prefix + 'thighs', 'Retuns an image of thighs')
.addField(prefix + 'trap', 'Returns a trap image')
.setFooter(pageData);
sent.edit(embed);
break;
}

if (page > max) {
page = max;
}

if (page < min) {
page = min;
}
}
}, {
time: 35000,
});
});
return;
execute(message, args, client, prefix, nsfwCmds) {
if (!args.length) {
const embedBuilder = new EmbedBuilder()
.setChannel(message.channel)
.setTime(35000);
const cmds = client.commands.array().filter(cmd => cmd.nsfw !== true);
cmds.sort((a, b) => (a.name > b.name) ? 1 : -1);
let method = Math.floor(cmds.length / 8) - 1;
let pages = 0;
for (let i = -1; i < method; i++) {
pages++;
embedBuilder.addEmbed(new Discord.RichEmbed());
method = Math.floor(cmds.length / 8);
}
let multiplier = 1;
for (let i = 0; i < 8 * multiplier; i++) {
if (i === cmds.length)
break;
if (cmds[i]) {
const cmd = cmds[i];
embedBuilder.getEmbeds()[multiplier - 1]
.addField(`${prefix}${cmd.name}`, cmd.description)
.setFooter(`Page ${multiplier}/${pages}`);
if (i === (8 * multiplier) - 1)
multiplier++;
}
}
embedBuilder.getEmbeds()[embedBuilder.getEmbeds().length - 1].addField('NSFW Commands', `${prefix}help nsfw`);
return embedBuilder
.setTitle('Commands')
.build();
}
if (args[0].toLowerCase() === "nsfw") {
const embedBuilder = new EmbedBuilder()
.setChannel(message.channel)
.setTime(35000);
let method = Math.floor(nsfwCmds.length / 8) - 1;
let pages = 0;
for (let i = -1; i < method; i++) {
pages++;
embedBuilder.addEmbed(new Discord.RichEmbed());
method = Math.floor(nsfwCmds.length / 8);
}
let multiplier = 1;
for (let i = 0; i < 8 * multiplier; i++) {
if (i === nsfwCmds.length)
break;
if (nsfwCmds[i]) {
const cmd = nsfwCmds[i];
embedBuilder.getEmbeds()[multiplier - 1]
.addField(`${prefix}${cmd.name}`, cmd.description)
.setFooter(`Page ${multiplier}/${pages}`);
if (i === (8 * multiplier) - 1)
multiplier++;
}
}
return embedBuilder
.setTitle('NSFW Commands')
.build();
}
const cmd = client.commands.get(args[0].toLowerCase());
if (!cmd) {
return message.channel.send(message.author + ' That command does not exist!');
const cmds = client.commands.array().filter(c => c.name.includes(args[0].toLowerCase()));
if (!cmds.length)
return message.channel.send(message.author + ' That command does not exist!');
const embedBuilder = new EmbedBuilder()
.setChannel(message.channel)
.setTime(35000);
let pages = 0;
let m = 1;
for (let i = 0; i < 8 * m; i++) {
if (i === cmds.length)
break;
if (!embedBuilder.getEmbeds()[m - 1]) {
embedBuilder.addEmbed(new Discord.RichEmbed());
pages++;
}
if (i === (8 * m) - 1)
m++;
}
let multiplier = 1;
for (let i = 0; i < 8 * multiplier; i++) {
if (i === cmds.length)
break;
if (cmds[i]) {
const c = cmds[i];
embedBuilder.getEmbeds()[multiplier - 1]
.addField(`${prefix}${c.name}`, c.description)
.setFooter(`Page ${multiplier}/${pages}`);
if (i === (8 * multiplier) - 1)
multiplier++;
}
}
return embedBuilder
.setTitle(`Results with: ${args[0].toLowerCase()}`)
.build();
}
const {
usage,
Expand Down
1 change: 1 addition & 0 deletions commands/r34xxx.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
name: 'r34xxx',
usage: '[tags]',
description: 'Returns an image from rule34',
nsfw: true,
execute(message, args) {
message.delete(1000);
if (!message.channel.nsfw) {
Expand Down
Loading

0 comments on commit aef7957

Please sign in to comment.