From dca44ea236dfddb9c14fff4c92656b0eb223a101 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 15:42:34 -0400 Subject: Whee new features! --- bot.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 4962977..e6983ad 100644 --- a/bot.js +++ b/bot.js @@ -2,9 +2,16 @@ const Discord = require('discord.js'); const bot = new Discord.Client(); const config = require('./config.json'); const fs = require('fs'); +const readline = require('readline'); const DBL = require('dblapi.js'); bot.dbl = new DBL(config.dbltoken, bot); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: '> ' +}); + bot.commands = new Discord.Collection(); bot.aliases = new Discord.Collection(); bot.categories = new Discord.Collection(); @@ -90,6 +97,63 @@ const nodes = [ { 'host': 'localhost', 'port': 6547, 'region': 'us', 'shard': 1, 'password': 'iamaverysecurepassword' }, ]; +rl.on('line', function(cmd){ + var args = cmd.split(" "); + switch(args[0]) { + case "guilds": + if (client.guilds.size === 0) { + console.log(('[!] No guilds found.')); + } 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}`); + } + } + break; + case "leave": + if (!args[1]) { + console.log('[!] Please insert the guild\'s ID.'); + } else { + var guild = client.guilds.get(args[1]); + guild.leave(); + } + break; + case "broadcast": + if (!args[1]) { + console.log('[!] Please insert the guild\'s ID.'); + } else { + let broadcast = args.join(" ").slice(48); + var guild = null; + guild = client.guilds.get(args[1]); + var channel = null; + channel = guild.channels.get(args[2]) + if (channel != null) { + channel.send(broadcast); + } + if (channel = null) { + console.log ('Usage: broadcast [guildID] [channelID]') + } + } + break; + case "exit": + console.log('[i] AleeBot will now exit!') + process.exit(0); + break; + case "help": + var msg = (`AleeBot `+ settings.abVersion +` Console Help\n\n`); + msg += (`guilds - Shows all guilds that AleeBot's on.\n`) + msg += (`leave - Leaves a guild.\n`) + msg += (`broadcast - Broadcasts a message to a server.\n`) + msg += (`help - Shows this command.\n`) + msg += (`exit - Exits AleeBot.\n`) + console.log(msg); + break; + default: + console.log('Unknown Command type \'help\' to list the commands...') + } + rl.prompt(); +}); + process.on('unhandledRejection', (err) => { console.error(err.stack); bot.Raven.captureException(err); -- cgit v1.2.3 From 5f20cd1070ed091bdefd57b6bf23fd7f3d9b1c64 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 15:50:08 -0400 Subject: trying something --- bot.js | 1 + 1 file changed, 1 insertion(+) (limited to 'bot.js') diff --git a/bot.js b/bot.js index e6983ad..02cdf00 100644 --- a/bot.js +++ b/bot.js @@ -161,4 +161,5 @@ process.on('unhandledRejection', (err) => { bot.login(config.token).then(() => { bot.player = new PlayerManager(bot, nodes, { user: bot.user.id, shards: 1, password: 'iamaverysecurepassword' }); + rl.prompt(); }); -- cgit v1.2.3 From 3af4e5d26a2facc4f58a77a6947d0cabc1d9f112 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 15:51:44 -0400 Subject: THIS IS NOT ALEEBOT! --- bot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 02cdf00..62d4b11 100644 --- a/bot.js +++ b/bot.js @@ -136,11 +136,11 @@ rl.on('line', function(cmd){ } break; case "exit": - console.log('[i] AleeBot will now exit!') + console.log('[i] PokeBot will now exit!') process.exit(0); break; case "help": - var msg = (`AleeBot `+ settings.abVersion +` Console Help\n\n`); + var msg = (`PokeBot Console Help\n\n`); msg += (`guilds - Shows all guilds that AleeBot's on.\n`) msg += (`leave - Leaves a guild.\n`) msg += (`broadcast - Broadcasts a message to a server.\n`) -- cgit v1.2.3 From 33fb1126935e6a8d8b192a315cce523c7b8213ad Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 15:52:33 -0400 Subject: oof --- bot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 62d4b11..d13f106 100644 --- a/bot.js +++ b/bot.js @@ -141,11 +141,11 @@ rl.on('line', function(cmd){ break; case "help": var msg = (`PokeBot Console Help\n\n`); - msg += (`guilds - Shows all guilds that AleeBot's on.\n`) + msg += (`guilds - Shows all guilds that PokeBot's on.\n`) msg += (`leave - Leaves a guild.\n`) msg += (`broadcast - Broadcasts a message to a server.\n`) msg += (`help - Shows this command.\n`) - msg += (`exit - Exits AleeBot.\n`) + msg += (`exit - Exits PokeBot.\n`) console.log(msg); break; default: -- cgit v1.2.3 From 872776a4f8270d1a57aba6391c9e175558b96b64 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 15:54:12 -0400 Subject: Client not defined... great job it's suppose to be bot.. --- bot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot.js') diff --git a/bot.js b/bot.js index d13f106..0bc043d 100644 --- a/bot.js +++ b/bot.js @@ -101,11 +101,11 @@ rl.on('line', function(cmd){ var args = cmd.split(" "); switch(args[0]) { case "guilds": - if (client.guilds.size === 0) { + if (bot.guilds.size === 0) { console.log(('[!] No guilds found.')); } else { console.log('[i] Here\'s the servers that AleeBot is connected to:') - for ([id, guild] of client.guilds) { + for ([id, guild] of bot.guilds) { console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`); } } @@ -114,7 +114,7 @@ rl.on('line', function(cmd){ if (!args[1]) { console.log('[!] Please insert the guild\'s ID.'); } else { - var guild = client.guilds.get(args[1]); + var guild = bot.guilds.get(args[1]); guild.leave(); } break; @@ -124,7 +124,7 @@ rl.on('line', function(cmd){ } else { let broadcast = args.join(" ").slice(48); var guild = null; - guild = client.guilds.get(args[1]); + guild = bot.guilds.get(args[1]); var channel = null; channel = guild.channels.get(args[2]) if (channel != null) { -- cgit v1.2.3 From 4a4841f22f26a4c0d92009883dcccd597984c250 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 18:20:52 -0400 Subject: Channels command for console --- bot.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 0bc043d..ad413ab 100644 --- a/bot.js +++ b/bot.js @@ -110,6 +110,17 @@ rl.on('line', function(cmd){ } } break; + case "channels": + if (!args[1]) { + console.log('[!] Please insert the guild\'s ID.') + } else { + var guild = client.guilds.get(args[1]); + console.log('[i] Here\'s the channels that this guild have:') + for ([id, channel, guild] of guild && client.channels) { + console.log(` Channel: #${channel.name} - ID: ${channel.id}`); + } + } + break; case "leave": if (!args[1]) { console.log('[!] Please insert the guild\'s ID.'); -- cgit v1.2.3 From d963a80f412fb42752d79a652a0bb6d3a578644e Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 22 Apr 2018 18:21:46 -0400 Subject: Forgot this... --- bot.js | 1 + 1 file changed, 1 insertion(+) (limited to 'bot.js') diff --git a/bot.js b/bot.js index ad413ab..ed2096a 100644 --- a/bot.js +++ b/bot.js @@ -153,6 +153,7 @@ rl.on('line', function(cmd){ case "help": var msg = (`PokeBot Console Help\n\n`); msg += (`guilds - Shows all guilds that PokeBot's on.\n`) + msg += (`channels - Shows all the channels that the guilds have.\n`) msg += (`leave - Leaves a guild.\n`) msg += (`broadcast - Broadcasts a message to a server.\n`) msg += (`help - Shows this command.\n`) -- cgit v1.2.3