Skip to content

Commit

Permalink
Merge pull request #2 from brussell98/Indev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
brussell98 committed Jan 24, 2016
2 parents 2db00a7 + 4559a76 commit ad8aa98
Show file tree
Hide file tree
Showing 17 changed files with 442 additions and 323 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.tmp
logs/*
*.env
227 changes: 104 additions & 123 deletions BrussellBot.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: node BrussellBot.js --harmony
bot: node BrussellBot.js --harmony
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ An multipurpose bot for Discord using the [Discord.js](https://github.com/hydrab

### TODO

- [ ] Music commands - After discord.js gets patched for volume
- [ ] Music commands
- [ ] Audio help
- [ ] Queue song from youtube
- [ ] Or pass it a webm link
Expand All @@ -27,4 +27,3 @@ An multipurpose bot for Discord using the [Discord.js](https://github.com/hydrab
- [ ] List of queues songs
- [ ] Set playing to song name
- [ ] Bot owner gets priority
- [ ] Could do stuff with checking how long a user has been on the server for perms
5 changes: 3 additions & 2 deletions bot/cleverbot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var Cleverbot = require('cleverbot-node');
var Slave = new Cleverbot();
var ent = require('entities');

exports.cleverbot = function(bot, msg) {
var text = msg.content.substring(22);
Expand All @@ -17,10 +18,10 @@ exports.cleverbot = function(bot, msg) {
return String.fromCharCode(parseInt(grp, 16));
});
}
bot.sendMessage(msg, ":speech_balloon: "+resp.message);
bot.sendMessage(msg, ":speech_balloon: "+ent.decodeHTML(resp.message));
});
} catch(error) { bot.sendMessage(msg, ":warning: There was an error", function (erro, wMessage) { bot.deleteMessage(wMessage, {"wait": 8000}); }); }
});
bot.stopTyping(msg.channel);
} else { bot.sendMessage(msg, "What is it?"); } //if no suffix
} else { bot.sendMessage(msg, "Yes?"); } //if no suffix
};
326 changes: 216 additions & 110 deletions bot/commands.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions bot/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"mod_command_prefix": "_",
"non_essential_event_listeners": true,
"log_presence": false,
"debug": false,
"admin_id": 95286900801146880,
"greet_new_members": false,
"username_changes": false,
"send_mentions": true,
"mal_user": "",
"mal_pass": "",
"is_heroku_version": true,
Expand Down
8 changes: 3 additions & 5 deletions bot/games.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
"kappa kappa kappa",
"no waifu no laifu",
"your waifu is trash",
"nothing",
"something",
"Kancolle",
"with you",
"node.js",
"discord.js",
"with itself",
"osu!",
"Bad Rats",
"Anime",
Expand All @@ -24,7 +22,6 @@
"Animaaayyyy lmao",
"Ayyyy lmao",
"Jet fuel can't melt dank memes",
"dank memes",
"with nekos",
"with fire",
"with your ❤",
Expand All @@ -35,5 +32,6 @@
"who is this Bot-chan?",
"world domination",
"dank memes",
"]help [command]"
"]help [command]",
"what's an anime?"
]}
55 changes: 0 additions & 55 deletions bot/logger.js

This file was deleted.

33 changes: 17 additions & 16 deletions bot/mod.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var config = require("./config.json");
var games = require("./games.json").games;
var version = require("../package.json").version;
var logger = require("./logger.js").Logger;
var fs = require('fs');
var colors = require('./styles.js');

var confirmCodes = []; //stuff for announce
var announceMessages = [];
Expand Down Expand Up @@ -62,7 +62,7 @@ var commands = {
if (msg.author.id == config.admin_id || msg.channel.isPrivate || msg.author.id == msg.channel.server.owner.id) {
var msgArray = [];
msgArray.push("```");
msgArray.push("Uptime: " + (Math.round(bot.uptime / (1000 * 60 * 60))) + " hours, " + (Math.round(bot.uptime / (1000 * 60)) % 60) + " minutes, and " + (Math.round(bot.uptime / 1000) % 60) + " seconds.");
msgArray.push("Uptime (may be inaccurate): " + (Math.round(bot.uptime / (1000 * 60 * 60))) + " hours, " + (Math.round(bot.uptime / (1000 * 60)) % 60) + " minutes, and " + (Math.round(bot.uptime / 1000) % 60) + " seconds.");
msgArray.push("Connected to " + bot.servers.length + " servers and " + bot.channels.length + " channels.");
msgArray.push("Serving " + bot.users.length + " users.");
msgArray.push("Memory Usage: " + Math.round(process.memoryUsage().rss/1024/1000)+"MB");
Expand All @@ -72,7 +72,7 @@ var commands = {
msgArray.push("```");
bot.sendMessage(msg, msgArray);

if (suffix.indexOf("-ls") != -1 && msg.channel.isPrivate) { //if user wants a list of servers
if (suffix.indexOf("-ls") != -1 && msg.channel.isPrivate) { //if user wants a list of servers NEED TO PAGINATE AND FORMAT BETTER
var svrArray = [];
for (svrObj of bot.servers) { svrArray.push("`"+svrObj.name+": C: "+svrObj.channels.length+", U: "+svrObj.members.length+"`"); }
bot.sendMessage(msg, svrArray);
Expand All @@ -84,13 +84,13 @@ var commands = {
"playing": {
desc: "Allows the bot owner to set the game.",
usage: "[game]",
cooldown: 5,
cooldown: 10,
shouldDisplay: false,
deleteCommand: true,
process: function (bot, msg, suffix) {
if (msg.author.id == config.admin_id) {
if (!suffix) { bot.setPlayingGame(games[Math.floor(Math.random() * (games.length))]); }
else { bot.setPlayingGame(suffix); logger.log("info", "" + msg.author.username + " changed the playing status to: "+suffix); }
else { bot.setPlayingGame(suffix); if (config.debug) { console.log(colors.cDebug(" DEBUG ")+msg.author.username + " changed the playing status to: "+suffix); } }
} else { bot.setPlayingGame("with "+msg.author.username); }
}
},
Expand All @@ -103,9 +103,9 @@ var commands = {
if (suffix && /^\d+$/.test(suffix)) { //if suffix has digits
if (msg.channel.isPrivate || msg.channel.permissionsOf(msg.author).hasPermission("manageMessages") || msg.author.id == config.admin_id) {
bot.getChannelLogs(msg.channel, 100, function (error, messages) {
if (error) { logger.log("warn", "Something went wrong while fetching logs."); return; }
if (error) { console.log(colors.cWarn(" WARN ")+"Something went wrong while fetching logs."); return; }
else {
logger.log("debug", "Cleaning bot messages...");
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Cleaning bot messages..."); }
var todo = parseInt(suffix),
delcount = 0;
for (msg1 of messages) {
Expand All @@ -115,12 +115,12 @@ var commands = {
todo--;
}
if (todo == 0) {
logger.log("debug", "Done! Deleted " + delcount + " messages.");
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Done! Deleted " + delcount + " messages."); }
bot.stopTyping(msg.channel);
return;
}
}
logger.log("debug", "Done! Deleted " + delcount + " messages.");
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Done! Deleted " + delcount + " messages."); }
}
});
} else { bot.sendMessage(msg, ":warning: You must have permission to manage messages in this channel", function (erro, wMessage) { bot.deleteMessage(wMessage, {"wait": 8000}); }); }
Expand All @@ -138,9 +138,9 @@ var commands = {
if (msg.channel.permissionsOf(msg.author).hasPermission("manageMessages")) {
if (msg.channel.permissionsOf(bot.user).hasPermission("manageMessages")) {
bot.getChannelLogs(msg.channel, 100, function (error, messages) {
if (error) { logger.log("warn", "Something went wrong while fetching logs."); return; }
if (error) { console.log(colors.cWarn(" WARN ")+"Something went wrong while fetching logs."); return; }
else {
logger.log("debug", "Pruning messages...");
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Pruning messages..."); }
var todo = parseInt(suffix);
var hasTerm = false;
var term = "";
Expand All @@ -160,7 +160,7 @@ var commands = {
return;
}
}
logger.log("debug", "Done! Deleted " + delcount + " messages.");
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Done! Deleted " + delcount + " messages."); }
}
});
} else { bot.sendMessage(msg, ":warning: I don't have permission to delete messages.", function (erro, wMessage) { bot.deleteMessage(wMessage, {"wait": 8000}); }); }
Expand All @@ -178,10 +178,10 @@ var commands = {
if (msg.channel.permissionsOf(msg.author).hasPermission("kickMembers") || msg.author.id == config.admin_id) {
bot.sendMessage(msg, "It's not like I want to be here or anything, baka").then(
bot.leaveServer(msg.channel.server));
logger.log("info", "I've left a server on request of " + msg.sender.username + ". I'm only in " + bot.servers.length + " servers now.");
console.log(colors.cYellow("I've left a server on request of " + msg.sender.username + ". ")+"I'm only in " + bot.servers.length + " servers now.");
} else {
bot.sendMessage(msg, "You can't tell me what to do! (You need permission to kick users in this channel)");
logger.log("info", "A non-privileged user (" + msg.sender.username + ") tried to make me leave a server.");
console.log(colors.cYellow("Non-privileged user: " + msg.sender.username)+" tried to make me leave a server.");
}
} else { bot.sendMessage(msg, ":warning: I can't leave a DM.", function (erro, wMessage) { bot.deleteMessage(wMessage, {"wait": 8000}); }); }
}
Expand All @@ -208,7 +208,7 @@ var commands = {
}, 1000); //1 message per second
}
});
logger.log("info", "Announced \"" + announceMessages[i] + "\" to servers");
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Announced \"" + announceMessages[i] + "\" to servers"); }
return;
}
} else {
Expand All @@ -230,7 +230,7 @@ var commands = {
bot.sendMessage(usr, ":mega: " + announceMessages[i] + " - from " + msg.author + " on " + msg.channel.server.name);
}, 1000);
});
logger.log("info", "Announced \"" + announceMessages[i] + "\" to members of "+msg.channel.server.name);
if (config.debug) { console.log(colors.cDebug(" DEBUG ")+"Announced \"" + announceMessages[i] + "\" to members of "+msg.channel.server.name); }
return;
}
} else {
Expand All @@ -247,6 +247,7 @@ var commands = {
desc: "See recent changes to the bot",
deleteCommand: true,
usage: "",
cooldown: 30,
process: function(bot, msg, suffix) {
var chanelogChannel = bot.channels.get("id", '135527608564580353');
if (!chanelogChannel) { bot.sendMessage(msg, "The bot is not in the BrussellBot Official Server", function (erro, wMessage) { bot.deleteMessage(wMessage, {"wait": 8000}); }); }
Expand Down
87 changes: 87 additions & 0 deletions bot/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
var chalk = require('chalk');
var enabled = new chalk.constructor({enabled: true});

exports.cWarn = function (text) {
return chalk.styles.bgYellow.open +
chalk.styles.black.open +
text +
chalk.styles.black.close +
chalk.styles.bgYellow.close +
chalk.styles.white.open + chalk.styles.bgBlack.open +" ";
};

exports.cError = function (text) {
return chalk.styles.bgRed.open +
chalk.styles.black.open +
text +
chalk.styles.black.close +
chalk.styles.bgRed.close +
chalk.styles.white.open + chalk.styles.bgBlack.open + " ";
};

exports.cDebug = function (text) {
return chalk.styles.bgWhite.open +
chalk.styles.black.open +
text +
chalk.styles.black.close +
chalk.styles.bgWhite.close +
chalk.styles.white.open + chalk.styles.bgBlack.open + " ";
};

exports.cGreen = function (text) {
return chalk.styles.green.open +
chalk.styles.bold.open +
text +
chalk.styles.bold.close +
chalk.styles.green.close + chalk.styles.white.open;
};

exports.cGrey = function (text) {
return chalk.styles.grey.open +
chalk.styles.bold.open +
text +
chalk.styles.grey.close +
chalk.styles.bold.close + chalk.styles.white.open;
};

exports.cYellow = function (text) {
return chalk.styles.yellow.open +
chalk.styles.bold.open +
text +
chalk.styles.yellow.close +
chalk.styles.bold.close + chalk.styles.white.open;
};

exports.cRed = function (text) {
return chalk.styles.red.open +
chalk.styles.bold.open +
text +
chalk.styles.red.close +
chalk.styles.bold.close + chalk.styles.white.open;
};

exports.cServer = function (text) {
return chalk.styles.magenta.open +
chalk.styles.bold.open +
text +
chalk.styles.magenta.close +
chalk.styles.bold.close + chalk.styles.white.open;
};

exports.cUYellow = function (text) {
return chalk.styles.yellow.open +
chalk.styles.underline.open +
chalk.styles.bold.open +
text +
chalk.styles.yellow.close +
chalk.styles.underline.close +
chalk.styles.bold.close + chalk.styles.white.open;
};

exports.cBgGreen = function (text) {
return chalk.styles.bgGreen.open +
chalk.styles.black.open +
text +
chalk.styles.bgGreen.close +
chalk.styles.black.close + chalk.styles.white.open + chalk.styles.bgBlack.open;
};
6 changes: 3 additions & 3 deletions bot/versioncheck.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var request = require("request");
var version = require("../package.json").version;
var logger = require("./logger.js").Logger;
var colors = require('./styles.js');

exports.checkForUpdate = function (callback) {
request("https://raw.githubusercontent.com/brussell98/BrussellBot/master/package.json", function (err, response, body) {
if (err) {
logger.log("warn", "Version check error: " + err);
console.log(colors.cWarn(" WARN ")+"Version check error: "+err);
return callback(null);
}
if (response.statusCode == 200) {
Expand All @@ -14,7 +14,7 @@ exports.checkForUpdate = function (callback) {
if ((version.split(".").join("")) > (latest.split(".").join(""))) { return callback("Bot is a development version (v" + version + ")"); }
return callback("BrussellBot is up-to-date (v" + version + ")");
} else {
logger.warn("Failed to check for new version: " + response.statusCode);
console.log(colors.cWarn(" WARN ")+"Failed to check for new version. Status code: "+response.statusCode);
return callback(null);
}
});
Expand Down
Empty file removed logs/debug.txt
Empty file.
Empty file removed logs/errors.txt
Empty file.
Empty file removed logs/exceptions.txt
Empty file.
Empty file removed logs/warn.txt
Empty file.
Loading

0 comments on commit ad8aa98

Please sign in to comment.