Skip to content

Commit

Permalink
Merge pull request #35 from muricans/mbot-testing
Browse files Browse the repository at this point in the history
7.6.0
  • Loading branch information
muricans authored Jun 9, 2019
2 parents 15ffed8 + 31fc84b commit fca3312
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 34 deletions.
9 changes: 2 additions & 7 deletions commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports.registerCommands = async (client, mbot) => {
const othercmds = [
'ping', 'test', 'meme', 'trap', 'thighs', 'rule34', 'pegging',
'nsfw', 'hentai', 'hardcore', 'gay', 'dick', 'boobs', 'blowjob',
'ass', 'anal', 'uptime', 'database',
'ass', 'anal', 'uptime',
];

function handleOther(command, message, args) {
Expand All @@ -90,10 +90,6 @@ module.exports.registerCommands = async (client, mbot) => {


switch (command) {
case "database":
const database = new Discord.Attachment('./mbot.db');
message.channel.send(database);
break;
case "uptime":
message.channel.send(`${message.author} mbot has been up for: ${mbot.getUptime()}`);
break;
Expand Down Expand Up @@ -237,7 +233,7 @@ module.exports.registerCommands = async (client, mbot) => {
}

client.on('message', async message => {
//if (message.author.bot) return;
if (message.author.bot) return;
if (!timer.users.has(message.author.id)) {
timer.users.set(message.author.id, new Discord.Collection());
const user = timer.users.get(message.author.id);
Expand All @@ -251,7 +247,6 @@ module.exports.registerCommands = async (client, mbot) => {
if (message.channel.type === 'dm') {
const args = message.content.split(' ');
const command = args.shift().toLowerCase();
if (message.author.bot) return;
switch (command) {
case "timer":
if (args.length < timer.minArgs) {
Expand Down
20 changes: 10 additions & 10 deletions commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ module.exports = {
sent.awaitReactions((reaction, user) => {
if (user.id != client.user.id) {
if (reaction.emoji.name === "◀") {
reaction.remove(message.author);
reaction.remove(user);
page--;
} else if (reaction.emoji.name === "▶") {
reaction.remove(message.author);
reaction.remove(user);
page++;
}

Expand All @@ -59,7 +59,7 @@ module.exports = {
.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 20 users with the most points')
.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.`)
Expand All @@ -76,19 +76,19 @@ module.exports = {
.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 + 'suggest <suggestion>', 'Suggest a command or feature for the bot')
.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 + 'set <user> <points>', 'Sets the users points [admin only]')
.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.')
.addField(prefix + 'version', 'Returns the bot version and information')
.addField('NSFW Commands on Page 5+6', '🔞')
.setFooter(pageData);
Expand All @@ -101,22 +101,22 @@ module.exports = {
.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')
.addField(prefix + 'hentai', 'Returns a hentai image')
.addField(prefix + 'nsfw', 'Returns an nsfw image (Straight)')
.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')
.addField(prefix + 'dick', 'Returns an image of a dick')
.addField(prefix + 'gay', 'Returns a gay porn image')
.setFooter(pageData);
sent.edit(embed);
break;
Expand Down
43 changes: 37 additions & 6 deletions commands/roulette/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,37 @@ const db = new sqlite.Database('./mbot.db', (err) => {

module.exports = {
name: 'leaderboard',
description: 'Get up to 20 users with the most points',
description: 'Get up to 50 users with the most points',
async execute(message, args, client) {
const leaders = await leaderboard(message, client);
return message.channel.send(leaders);
let page = 0;
message.channel.send(leaders[page]).then(async sent => {
await sent.react('◀');
await sent.react('▶');
sent.awaitReactions((reaction, user) => {
if (user.id === client.user.id) return;
reaction.remove(user);
switch (reaction.emoji.name) {
case "◀":
if (page === 0) return;
page--;
break;
case "▶":
if (page === leaders.length - 1) return;
page++;
break;
}
sent.edit(leaders[page]);
}, (2 * 60000));
});
},
};

function leaderboard(message, client) {
return new Promise((resolve) => {
db.all('SELECT points points, id id FROM users ORDER BY points DESC', async (err, rows) => {
if (err) return console.log(err);
const embed = new Discord.RichEmbed().setTitle('Points Leaderboard');
const embeds = [];
if (!rows.length) return message.channel.send('No users found!');
const each = new Promise(async (resolve) => {
const users = [];
Expand All @@ -31,14 +50,26 @@ function leaderboard(message, client) {
return resolve(users);
});
await each.then(async users => {
for (let i = 0; i < 20; i++) {
let method = Math.floor(users.length / 10) - 1;
for (let i = -1; i < method; i++) {
embeds.push(new Discord.RichEmbed());
method = Math.floor(users.length / 10);
}
let multiplier = 1;
for (let i = 0; i < 10 * multiplier; i++) {
if (i === 50) {
break;
}
if (users[i]) {
const user = await client.fetchUser(users[i].id);
embed.addField(`${i + 1}. ${user.username}`, users[i].points, true);
embeds[multiplier - 1].addField(`${i + 1}. ${user.username}`, users[i].points, true);
if (i === (10 * multiplier) - 1) {
multiplier++;
}
}
}
});
return resolve(embed);
return resolve(embeds);
});
});
}
22 changes: 17 additions & 5 deletions mbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,29 @@ process.openStdin().on('data', (val) => {
case "version":
require('fs').readFile('./version.txt', 'utf8', (err, data) => {
if (err) return Logger.error(err.stack);
Logger.info(
`Application: mbot\n Version: ${pkg.version}\n Author: Muricans\n Git repo: https://github.com/muricans/mbot\n Git commit: ${data}\n Website: https://muricans.github.io/mbot`
);
Logger.info(`Application: mbot
Version: ${pkg.version}
Author: Muricans
Git repo: https://github.com/muricans/mbot
Git commit: ${data}
Website: https://muricans.github.io/mbot`);
});
break;
case "help":
Logger.info(`Commands:
stop - stops the bot
version - gets the bots version and other information`);
break;
}
});

process.on('exit', (code) => {
Logger.info(`mbot v${pkg.version} has exited with code (${code})`);
});

setTimeout(() => {
if (!alive) {
Logger.warn("Bot is having trouble contacting discord...");
Logger.warn("mbot is having trouble contacting discord...");
setTimeout(() => {
Logger.error("Failed to contact discord, stopping bot.");
process.exit(1);
Expand All @@ -310,7 +322,7 @@ client.login(settings.token).then(() => {
if (settings.debug) {
return console.log(err);
} else {
console.log('There was an error starting the bot. Maybe check credentials?\nTo check the actual error, enable debug in your settings file.');
Logger.error('There was an error starting the bot. Maybe check credentials?\nTo check the actual error, enable debug in your settings file.');
}
}
});
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mbot",
"version": "7.5.5",
"version": "7.6.0",
"description": "Private discord bot",
"main": "mbot.js",
"scripts": {
Expand All @@ -11,7 +11,7 @@
"dependencies": {
"chalk": "^2.4.2",
"crypto": "^1.0.1",
"discord.js": "^11.5.0",
"discord.js": "^11.5.1",
"discord.js-commando": "^0.9.0",
"figlet": "^1.2.3",
"newsapi": "^2.4.0",
Expand Down

0 comments on commit fca3312

Please sign in to comment.