Console colors and 2.10.0 Beta

This commit is contained in:
Andrew Lee 2018-06-01 22:17:04 -04:00
parent d02bfd99dc
commit 1f95f9c4c5
2 changed files with 40 additions and 43 deletions

View file

@ -20,6 +20,7 @@
const Discord = require('discord.js');
const moment = require('moment');
const readline = require('readline');
const colors = require('colors');
const DBL = require("dblapi.js");
const client = new Discord.Client({
disableEveryone: true
@ -31,30 +32,30 @@ const dbl = new DBL(api.dbltoken, client);
const log = message => {
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`);
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`.white);
};
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: '> '
prompt: '> '.gray
});
console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2018 AleeCorp`);
console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.');
console.log ('This is free software, and you are welcome to redistribute it');
console.log ('under certain conditions; type `show c\' for details.\n')
console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2018 AleeCorp`.gray);
console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.'.gray);
console.log ('This is free software, and you are welcome to redistribute it'.gray);
console.log ('under certain conditions; type `show c\' for details.\n'.gray)
if (process.argv.indexOf("--debug") == -1) {
console.log("Running AleeBot without --debug command line flag. Debug output disabled.\n");
console.log("Running AleeBot without --debug command line flag. Debug output disabled.\n".yellow);
} else {
console.log('[!] Entering debug mode...')
console.log('[!] Entering debug mode...'.yellow)
client.on('debug', function(info) {
log(info);
log(info.gray);
});
client.on('warn', function(info) {
log(info);
log(info.red);
});
}
@ -63,23 +64,23 @@ client.aliases = new Discord.Collection();
fs.readdir('./commands', (err, files) => {
if (err) console.error(err);
log(`[!] Attempting to load a total of ${files.length} commands into the memory.`);
log(`[!] Attempting to load a total of ${files.length} commands into the memory.`.cyan);
files.forEach(file => {
try {
const command = require(`./commands/${file}`);
log(`[!] Attempting to load the command "${command.help.name}".`);
log(`[!] Attempting to load the command "${command.help.name}".`.cyan);
client.commands.set(command.help.name, command);
command.conf.aliases.forEach(alias => {
client.aliases.set(alias, command.help.name);
log(`[!] Attempting to load "${alias}" as an alias for "${command.help.name}"`);
log(`[!] Attempting to load "${alias}" as an alias for "${command.help.name}"`.cyan);
});
}
catch (err) {
log('[X] An error has occured trying to load a command. Here is the error.');
log('[X] An error has occured trying to load a command. Here is the error.'.red);
console.log(err.stack);
}
});
log('[>] Command Loading complete!');
log('[>] Command Loading complete!'.green);
console.log('\n');
});
@ -88,28 +89,28 @@ rl.on('line', function(cmd){
switch(args[0]) {
case "guilds":
if (client.guilds.size === 0) {
console.log(('[!] No guilds found.'));
console.log(('[!] No guilds found.'.yellow));
} else {
console.log('[i] Here\'s the servers that AleeBot is connected to:')
for ([id, guild] of client.guilds) {
console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`);
console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`.blue);
}
}
break;
case "channels":
if (!args[1]) {
console.log('[!] Please insert the guild\'s ID.')
console.log('[!] Please insert the guild\'s ID.'.yellow)
} else {
var guild = client.guilds.get(args[1]);
console.log('[i] Here\'s the channels that this guild have:')
console.log('[i] Here\'s the channels that this guild have:'.blue)
for ([id, channel, guild] of guild && client.channels) {
console.log(` Channel: #${channel.name} - ID: ${channel.id}`);
console.log(` Channel: #${channel.name} - ID: ${channel.id}`.blue);
}
}
break;
case "leave":
if (!args[1]) {
console.log('[!] Please insert the guild\'s ID.');
console.log('[!] Please insert the guild\'s ID.'.yellow);
} else {
var guild = client.guilds.get(args[1]);
guild.leave();
@ -117,7 +118,7 @@ rl.on('line', function(cmd){
break;
case "broadcast":
if (!args[1]) {
console.log('[!] Usage: broadcast [guildID] [channelID].');
console.log('[!] Usage: broadcast [guildID] [channelID].'.yellow);
} else {
let broadcast = args.join(" ").slice(48);
var guild = null;
@ -140,10 +141,10 @@ rl.on('line', function(cmd){
uptimeMinutes = uptimeMinutes - 60;
}
const uptimeSeconds = minutes % 60;
console.log('[i] AleeBot has been up for ' + hours + ' hours, ' + uptimeMinutes + ' minutes, and ' + uptimeSeconds + ' seconds.');
console.log(`[i] AleeBot has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`.blue);
break;
case "exit":
console.log('[i] AleeBot will now exit!')
console.log('[i] AleeBot will now exit!'.blue)
process.exit(0);
break;
case "help":
@ -155,22 +156,22 @@ rl.on('line', function(cmd){
msg += (`uptime - Shows the uptime for AleeBot.\n`)
msg += (`help - Shows this command.\n`)
msg += (`exit - Exits AleeBot.\n`)
console.log(msg);
console.log(msg.cyan);
break;
default:
console.log('Unknown Command type \'help\' to list the commands...')
console.log('Unknown Command type \'help\' to list the commands...'.yellow)
}
rl.prompt();
});
client.on('ready', () => {
log('[>] AleeBot is now ready!');
log(`[i] Logged in as ${client.user.tag}`);
log(`[i] Default Prefix: ${settings.prefix}`)
log(`[i] Bot ID: ${client.user.id}`);
log(`[i] Token: ${api.abtoken}`);
log('[i] Running version ' + settings.abVersion + ` and in ${client.guilds.size} guilds`);
log('[>] AleeBot is now ready!'.green);
log(`[i] Logged in as ${client.user.tag}`.green);
log(`[i] Default Prefix: ${settings.prefix}`.green)
log(`[i] Bot ID: ${client.user.id}`.green);
log(`[i] Token: ${api.abtoken}`.green);
log(`[i] Running version ${settings.abVersion} and in ${client.guilds.size} guilds`.green);
client.setInterval(function() {
const games = [
@ -199,7 +200,7 @@ client.on('ready', () => {
client.on('guildCreate', guild => {
log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`.blue);
message.author.send(':wave: Hello! Thanks for inviting AleeBot!\nFor help type `ab:help`, and if you want to set the prefix `ab:setprefix [prefix]`')
});
@ -207,7 +208,7 @@ client.on('guildCreate', guild => {
client.on('guildDelete', guild => {
log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`);
log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`.red);
});
@ -254,18 +255,14 @@ client.on('message', (msg) => {
process.on('unhandledRejection', function(err, p) {
log("[X | UNCAUGHT PROMISE] " + err.stack);
log("[X | UNCAUGHT PROMISE] " + err.stack.red);
});
process.on('uncaughtException', function (exception) {
log(exception);
});
client.on("error", error => {
log(error);
log(exception.red);
});
client.login(api.abtoken).catch(function() {
log('[X] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com.');
log('[X] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com.'.red);
});

View file

@ -1,4 +1,4 @@
{
"abVersion": "2.9.3",
"prefix": "ab:"
"abVersion": "2.10.0 Beta",
"prefix": "abb:"
}