AleeBot/aleebot.js

121 lines
4.1 KiB
JavaScript
Raw Normal View History

2017-05-31 16:26:45 -04:00
/****************************************
2017-07-29 15:46:00 -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');
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
var logsChannel = "318874545593384970";
client.on('ready', () => {
console.log("[SUCCESS] AleeBot is now ready! Running version "+ config.abversion +"!");
client.user.setPresence({ game: { name: 'with version '+ config.abversion +'', type: 0 } });
2017-08-17 21:11:48 -04:00
client.user.setStatus('online')
});
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-08-04 20:30:24 -04:00
2017-08-13 19:35:12 -04:00
2017-08-03 22:54:01 -04: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
if (word != -1) {
return true;
} else {
return false;
}
} */
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-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})`);
});
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;
if(message.content.indexOf(config.prefix) !== 0) return;
2017-07-29 16:31:10 -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
/* if (wordFilter(message.content))
{
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-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
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
});