2017-05-31 16:26:45 -04:00
|
|
|
/****************************************
|
2017-07-29 15:46:00 -04:00
|
|
|
*
|
2017-07-26 19:13:04 -04:00
|
|
|
* AleeBot for AleeArmy Community and other servers
|
|
|
|
* Copyright (C) 2017 AleeCorp
|
2017-05-31 16:26:45 -04:00
|
|
|
*
|
2017-08-13 20:59:45 -04:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2017-07-29 15:46:00 -04:00
|
|
|
*
|
2017-08-13 20:59:45 -04:00
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
**************************************/
|
2017-05-31 16:09:24 -04:00
|
|
|
const Discord = require('discord.js');
|
2017-08-16 01:22:34 -04:00
|
|
|
const blessed = require('blessed');
|
2017-08-17 01:40:08 -04:00
|
|
|
const fs = require('fs');
|
2017-05-31 16:09:24 -04:00
|
|
|
const client = new Discord.Client();
|
2017-07-29 17:57:02 -04:00
|
|
|
const config = require('./absettings.json');
|
2017-07-29 15:46:00 -04:00
|
|
|
|
2017-08-17 01:40:08 -04:00
|
|
|
|
2017-07-26 14:10:01 -07:00
|
|
|
var logsChannel = "318874545593384970";
|
|
|
|
|
2017-07-27 15:21:37 -04:00
|
|
|
client.on('ready', () => {
|
2017-08-17 01:40:08 -04:00
|
|
|
console.log("[SUCCESS] AleeBot is now ready! Running version "+ config.abversion +"!");
|
|
|
|
});
|
|
|
|
|
|
|
|
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, ...args));
|
|
|
|
});
|
2017-07-27 15:21:37 -04:00
|
|
|
});
|
2017-08-04 20:30:24 -04:00
|
|
|
|
2017-08-13 19:35:12 -04:00
|
|
|
|
2017-08-17 20:51:15 -04:00
|
|
|
function setGame() {
|
|
|
|
var presence = {
|
|
|
|
game: {
|
|
|
|
type: 0
|
|
|
|
},
|
|
|
|
status: "online",
|
|
|
|
|
|
|
|
afk: false
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (Math.floor(Math.random() * 1000) % 35) {
|
|
|
|
case 0:
|
|
|
|
presence.game.name = "For help: ab:help";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
presence.game.name = "Running version "+ config.abversion +"";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
presence.game.name = `Running on ${client.guilds.size} servers`;
|
|
|
|
case 3:
|
|
|
|
presence.game.name = "with other bots c:"
|
|
|
|
}
|
|
|
|
client.user.setPresence(presence);
|
|
|
|
}
|
|
|
|
|
2017-08-03 22:54:01 -04:00
|
|
|
/*
|
2017-07-26 14:10:01 -07:00
|
|
|
function wordFilter(content) {
|
|
|
|
var word = content.search(/\b(fuck|fag|faggot|fuck|fuk|fuc|fucc|ho|phuck|hentai|porn|slut|bitch|succ|fucking|shit|ass|asshole|mofo|motherfucker|fucker|damn|hell|dick|cock|sex|cunt|nigger|nigga)+\b/i);
|
2017-07-29 15:46:00 -04:00
|
|
|
|
2017-07-26 14:10:01 -07:00
|
|
|
if (word != -1) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-27 12:22:34 -04:00
|
|
|
} */
|
2017-06-01 22:26:22 +00:00
|
|
|
|
2017-07-31 16:46:27 -04:00
|
|
|
|
|
|
|
client.on("guildCreate", guild => {
|
|
|
|
|
|
|
|
// This event triggers when the bot joins a guild.
|
|
|
|
|
|
|
|
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
|
|
|
|
|
|
|
|
|
2017-08-17 15:31:48 -04:00
|
|
|
guild.defaultChannel.sendMessage(":wave: Hello I am AleeBot thanks for inviting me to your server for help type `"+ config.prefix +"help`.")
|
2017-08-12 00:42:28 -04:00
|
|
|
|
2017-07-31 16:46:27 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client.on("guildDelete", guild => {
|
|
|
|
|
|
|
|
// this event triggers when the bot is removed from a guild.
|
|
|
|
|
|
|
|
console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-07-26 14:10:01 -07:00
|
|
|
client.on("message", function(message){
|
2017-07-29 16:31:10 -04:00
|
|
|
if (message.author.bot) return;
|
2017-08-16 00:04:57 -04:00
|
|
|
if (message.channel.type === "dm") return;
|
2017-08-17 01:40:08 -04:00
|
|
|
if(message.content.indexOf(config.prefix) !== 0) return;
|
2017-07-29 16:31:10 -04:00
|
|
|
|
2017-08-17 01:40:08 -04:00
|
|
|
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, config);
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
2017-07-29 16:31:10 -04:00
|
|
|
|
2017-07-27 12:22:34 -04:00
|
|
|
/* if (wordFilter(message.content))
|
2017-07-26 14:10:01 -07:00
|
|
|
{
|
|
|
|
message.delete();
|
|
|
|
client.channels.get('318874545593384970').sendMessage(":information_source: " + message.author.username + " just swore!");
|
|
|
|
console.log("[INFO] " + message.author.username + " just swore!");
|
|
|
|
switch (Math.floor(Math.random() * 1000) % 3) {
|
|
|
|
message.reply("You have been caught swearing.");
|
|
|
|
message.author.send("You have been caught swearing in AleeArmy Community.");
|
2017-07-27 12:22:34 -04:00
|
|
|
} */
|
2017-07-29 15:46:00 -04:00
|
|
|
|
2017-06-06 20:18:46 +00:00
|
|
|
});
|
2017-06-01 22:26:22 +00:00
|
|
|
|
2017-07-30 20:21:18 -04:00
|
|
|
process.on('unhandledRejection', function(err, p) {
|
2017-07-29 21:42:13 -04:00
|
|
|
console.log("[ERROR | UNCAUGHT PROMISE] " + err.stack);
|
|
|
|
});
|
2017-07-29 15:46:00 -04:00
|
|
|
|
2017-08-14 15:41:55 -04:00
|
|
|
client.login (config.abtoken).catch(function() {
|
2017-07-27 15:59:49 -04:00
|
|
|
console.log("[ERROR] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com.");
|
2017-05-31 16:09:24 -04:00
|
|
|
});
|