aboutsummaryrefslogtreecommitdiff
path: root/src/bot.js
diff options
context:
space:
mode:
authorUnknown <Alee14498@gmail.com>2017-10-27 09:11:04 -0400
committerUnknown <Alee14498@gmail.com>2017-10-27 09:11:04 -0400
commitd9812248364eafe698685bdc583f3f69c00e5660 (patch)
tree32b156c51fc361aa89125a55640fc6d3a1be6c4a /src/bot.js
parenta8fdb157a61612f38890d1e9f73b6d4c2b4aaac6 (diff)
downloadAleeBot-d9812248364eafe698685bdc583f3f69c00e5660.tar.gz
AleeBot-d9812248364eafe698685bdc583f3f69c00e5660.tar.bz2
AleeBot-d9812248364eafe698685bdc583f3f69c00e5660.zip
Added modular to AleeBot (but guildMemberAdd is broken)
Diffstat (limited to 'src/bot.js')
-rw-r--r--src/bot.js41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/bot.js b/src/bot.js
index a3226d4..c8adba9 100644
--- a/src/bot.js
+++ b/src/bot.js
@@ -1,16 +1,28 @@
/*********************************************
*
- * AleeBot for Discord servers
- * Copyright (C) 2017 AleeCorp
- * License: MIT
+ * AleeBot for Discord servers
+ * Copyright (C) 2017 AleeCorp
+ * License: MIT
*
**********************************************/
const Discord = require('discord.js');
const client = new Discord.Client();
const abVersion = "2.0.0 Beta";
const prefix = "abb:"
+const fs = require("fs");
const config = require('./absettings.json');
+fs.readdir("./events/", (err, files) => {
+ if (err) return console.error(err);
+ files.forEach(file => {
+ let eventFunction = require(`./events/${file}`);
+ let eventName = file.split(".")[0];
+ // super-secret recipe to call events with all their proper arguments *after* the `client` var.
+ client.on(eventName, (...args) => eventFunction.run(client,abVersion, ...args));
+ });
+});
+
+/*
client.on('ready', () => {
console.log("[>] AleeBot is now ready!")
console.log("[i] Running version " + abVersion + ` and in ${client.guilds.size} guilds`)
@@ -21,7 +33,7 @@ client.on('ready', () => {
}
});
client.user.setStatus('online')
-});
+}); */
client.on("guildCreate", guild => {
@@ -50,10 +62,10 @@ client.on("guildDelete", guild => {
});
-
+/*
client.on('guildMemberAdd', member => {
member.guild.channels.find("name", "welcomes-and-byes").sendMessage(member.toString() + " has joined the server");
-});
+}); */
client.on('guildMemberRemove', member => {
member.guild.channels.find("name", "welcomes-and-byes").sendMessage(`**${member.user.username}** has left the server`);
@@ -65,11 +77,16 @@ client.on("message", function(message) {
if (message.channel.type === "dm") return;
if (message.content.indexOf(config.prefix) !== 0) return;
- let command = message.content.split(" ")[0];
- command = command.slice(prefix.length);
-
- let args = message.content.split(" ").slice(1);
-
+ const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
+ const command = args.shift().toLowerCase();
+
+ try {
+ let commandFile = require(`./commands/${command}.js`);
+ commandFile.run(client, message, args);
+ } catch (err) {
+ message.reply(`The command ${command} is invalid buddy try to do ab:help`);
+ }
+ /*
if (command === 'help') {
var embed = new Discord.RichEmbed()
.setAuthor('AleeBot ' + abVersion + ' Commands', "https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048")
@@ -96,7 +113,7 @@ client.on("message", function(message) {
var uptimeSeconds = minutes % 60;
message.channel.send(":clock3: AleeBot has been up for " + hours + " hours, " + uptimeMinutes + " minutes, and " + uptimeSeconds + " seconds.")
}
-
+ */
});
client.login(config.abtoken).catch(function() {
console.log("[X] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com.");