aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--bot.js171
-rw-r--r--commands/help.js61
-rw-r--r--package-lock.json64
-rw-r--r--package.json23
-rw-r--r--storage/settings.json4
6 files changed, 325 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index ad46b30..f23544f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,3 +59,5 @@ typings/
# next.js build output
.next
+.vs/slnx.sqlite
+tokens.json
diff --git a/bot.js b/bot.js
new file mode 100644
index 0000000..ab44b81
--- /dev/null
+++ b/bot.js
@@ -0,0 +1,171 @@
+/****************************************
+ *
+ * StandBot: Made for discord servers
+ * Copyright (C) 2018 AleeCorp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * *************************************/
+const Discord = require('discord.js');
+const moment = require('moment');
+const readline = require('readline');
+const colors = require('colors');
+const client = new Discord.Client({
+ disableEveryone: true
+});
+const settings = require('./storage/settings.json')
+const fs = require('fs');
+const api = require('./tokens.json');
+const ownerID = "242775871059001344";
+
+const log = message => {
+
+ console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`.white);
+
+};
+
+
+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".yellow);
+} else {
+ console.log('[!] Entering debug mode...'.yellow)
+ client.on('debug', function(info) {
+ log(info.gray);
+ });
+ client.on('warn', function(info) {
+ log(info.red);
+ });
+}
+
+
+client.commands = new Discord.Collection();
+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.`.cyan);
+ files.forEach(file => {
+ try {
+ const command = require(`./commands/${file}`);
+ 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}"`.cyan);
+ });
+ }
+ catch (err) {
+ log('[X] An error has occured trying to load a command. Here is the error.'.red);
+ console.log(err.stack);
+ }
+ });
+ log('[>] Command Loading complete!'.green);
+ console.log('\n');
+});
+
+
+client.on('ready', () => {
+ log('[>] StandBot 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.version} and in ${client.guilds.size} guilds`.green);
+
+ client.setInterval(function() {
+ const games = [
+ 'StandBot ' + settings.version + ' | ' + settings.prefix + 'help',
+ 'Annoying Alee',
+ 'Coding stuff',
+ 'Drawing shapes',
+ 'Fighting AstralMod',
+ ];
+ client.user.setPresence({
+ status: 'online',
+ afk: false,
+ game: {
+ type: 0,
+ name: games[Math.floor(Math.random() * games.length)],
+ },
+ });
+ }, 200000);
+ client.user.setStatus('online');
+});
+
+client.on('guildCreate', guild => {
+
+ log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`.blue);
+
+});
+
+
+client.on('guildDelete', guild => {
+
+ log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`.red);
+
+});
+
+
+client.on('message', (msg) => {
+ if (msg.author.bot) return;
+
+ if (!msg.content.startsWith(settings.prefix)) return;
+ const args = msg.content.slice(settings.prefix.length).trim().split(/ +/g);
+ const command = args.shift();
+ let cmd;
+
+ if (client.commands.has(command)) {
+ cmd = client.commands.get(command);
+ } else if (client.aliases.has(command)) {
+ cmd = client.commands.get(client.aliases.get(command));
+ }
+
+ if (cmd) {
+ if (cmd.conf.guildOnly == true) {
+ if (!msg.channel.guild) {
+ return msg.channel.createMessage('This command can only be ran in a guild.');
+ }
+ }
+ try {
+ cmd.run(client, msg, args);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+});
+
+process.on('unhandledRejection', function(err, p) {
+
+log("[X | UNCAUGHT PROMISE] " + err.stack.red);
+
+});
+client.on('reconnecting', function() {
+ log("[!] StandBot has disconnected from Discord and is now attempting to reconnect.".yellow);
+});
+
+client.on('disconnect', function() {
+ log("[X] StandBot has disconnected from Discord and will not attempt to reconnect.".red);
+ console.log("At this point, you'll need to restart StandBot.".red);
+});
+
+client.login(api.token).catch(function() {
+ console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red);
+ process.exit(0);
+ }); \ No newline at end of file
diff --git a/commands/help.js b/commands/help.js
new file mode 100644
index 0000000..cf68b45
--- /dev/null
+++ b/commands/help.js
@@ -0,0 +1,61 @@
+/****************************************
+ *
+ * Help: Command for AleeBot
+ * Copyright (C) 2018 AleeCorp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * *************************************/
+const Discord = require('discord.js');
+const fs = require('fs');
+module.exports.run = async (client, message) => {
+ const categories = [];
+ const commands = Array.from(client.commands.keys());
+ const settings = require('../storage/settings.json')
+ commands.forEach(function(x) {
+ if (!categories.includes(client.commands.get(x).help.category)) {
+ categories.push(client.commands.get(x).help.category);
+ }
+ });
+
+ if (!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return message.reply('ERROR: StandBot doesn\'t have the permission to send embed links please enable them to use the full help.');
+ const embed = new Discord.RichEmbed()
+ .setAuthor('StandBot ' + require('../storage/settings.json').version + ` Help and on ${client.guilds.size} servers`, client.user.avatarURL)
+ .setDescription('Every command you input into StandBot is `' + require('../storage/settings.json').prefix + '`.')
+ .setColor('#1fd619')
+ .setFooter('LAC-Corp Copyright 2018, Licensed with GPL-3.0');
+
+ categories.forEach(function(x) {
+ let cat = '';
+ commands.forEach(function(command) {
+ if (client.commands.get(command).help.category == x) {
+ cat = cat + command + '\n';
+ }
+ });
+ embed.addField(x, cat, true);
+ });
+
+ await message.channel.send({ embed });
+};
+
+exports.conf = {
+ aliases: ['h'],
+ guildOnly: false,
+};
+exports.help = {
+ name: 'help',
+ description: 'Displays all the commands or a page with information for 1 command.',
+ usage: 'help (command:command-name)',
+ category: '- General Commands',
+};
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..812f319
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,64 @@
+{
+ "name": "standbot",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "async-limiter": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
+ "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
+ },
+ "discord.js": {
+ "version": "11.3.2",
+ "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-11.3.2.tgz",
+ "integrity": "sha512-Abw9CTMX3Jb47IeRffqx2VNSnXl/OsTdQzhvbw/JnqCyqc2imAocc7pX2HoRmgKd8CgSqsjBFBneusz/E16e6A==",
+ "requires": {
+ "long": "^4.0.0",
+ "prism-media": "^0.0.2",
+ "snekfetch": "^3.6.4",
+ "tweetnacl": "^1.0.0",
+ "ws": "^4.0.0"
+ }
+ },
+ "fs": {
+ "version": "0.0.1-security",
+ "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
+ "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
+ },
+ "long": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
+ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
+ },
+ "prism-media": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.0.2.tgz",
+ "integrity": "sha512-L6yc8P5NVG35ivzvfI7bcTYzqFV+K8gTfX9YaJbmIFfMXTs71RMnAupvTQPTCteGsiOy9QcNLkQyWjAafY/hCQ=="
+ },
+ "safe-buffer": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ },
+ "snekfetch": {
+ "version": "3.6.4",
+ "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz",
+ "integrity": "sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw=="
+ },
+ "tweetnacl": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz",
+ "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins="
+ },
+ "ws": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
+ "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
+ "requires": {
+ "async-limiter": "~1.0.0",
+ "safe-buffer": "~5.1.0"
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..0e24bee
--- /dev/null
+++ b/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "standbot",
+ "version": "1.0.0",
+ "description": "",
+ "main": "bot.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/LAC-Corp/StandBot.git"
+ },
+ "author": "",
+ "license": "GPL-3.0",
+ "bugs": {
+ "url": "https://github.com/LAC-Corp/StandBot/issues"
+ },
+ "homepage": "https://github.com/LAC-Corp/StandBot#readme",
+ "dependencies": {
+ "discord.js": "^11.3.2",
+ "fs": "0.0.1-security"
+ }
+}
diff --git a/storage/settings.json b/storage/settings.json
new file mode 100644
index 0000000..451f3c7
--- /dev/null
+++ b/storage/settings.json
@@ -0,0 +1,4 @@
+{
+ "version": "1.0.0 Beta",
+ "prefix": "sb:"
+} \ No newline at end of file