diff options
Diffstat (limited to 'bot.js')
| -rw-r--r-- | bot.js | 140 |
1 files changed, 76 insertions, 64 deletions
@@ -92,74 +92,86 @@ fs.readdir('./events', (err, files) => { -/*rl.on('line', function(cmd) { - const args = cmd.split(' '); - switch (args[0]) { - case 'guilds': - if (bot.guilds.size === 0) { - console.log(('[!] No guilds found.')); - } else { - console.log('[i] Here\'s the servers that PokeBot is connected to:'); - for (const [id, guild] of bot.guilds) { - console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`); - } +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 Galaxy is connected to:') + for ([id, guild] of client.guilds) { + console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`); + } + } + 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.'); + } else { + var guild = client.guilds.get(args[1]); + guild.leave(); + } + break; + case "broadcast": + if (!args[1]) { + console.log('[!] Usage: broadcast [guildID] [channelID].'); + } 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); + } + } + break; + case "uptime": + let uptime = parseInt(client.uptime); + uptime = Math.floor(uptime / 1000); + let uptimeMinutes = Math.floor(uptime / 60); + const minutes = uptime % 60; + let hours = 0; + while (uptimeMinutes >= 60) { + hours++; + uptimeMinutes = uptimeMinutes - 60; } + const uptimeSeconds = minutes % 60; + console.log(`[i] Galaxy has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`); break; - case 'channels': - if (!args[1]) { - console.log('[!] Please insert the guild\'s ID.'); - } else { - var guild = bot.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.'); - } else { - var guild = bot.guilds.get(args[1]); - guild.leave(); - } - break; - case 'broadcast': - if (!args[1]) { - console.log('[!] Please insert the guild\'s ID.'); - } else { - const broadcast = args.join(' ').slice(48); - var guild = null; - guild = bot.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] PokeBot will now exit!'); - process.exit(0); - break; - 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'); - msg += ('exit - Exits PokeBot.\n'); - console.log(msg); - break; - default: - console.log('Unknown Command type \'help\' to list the commands...'); + case "exit": + console.log('[i] Galaxy will now exit!.') + process.exit(0); + break; + case "help": + var msg = (`Galaxy 2.0 Alpha 1 Console Help\n\n`); + msg += (`guilds - Shows all guilds that Galaxy'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 += (`uptime - Shows the uptime for Galaxy.\n`) + msg += (`help - Shows this command.\n`) + msg += (`exit - Exits Galaxy.\n`) + console.log(msg); + break; + default: + console.log('Unknown command, type \'help\' to list the commands...'.yellow) } rl.prompt(); -});*/ +}); + process.on('unhandledRejection', (err) => { console.error(err.stack); |
