aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnknown <Alee14498@gmail.com>2017-08-17 01:40:08 -0400
committerUnknown <Alee14498@gmail.com>2017-08-17 01:40:08 -0400
commit2a8c799d7a9ad46f398c5e2feb448140eecbc638 (patch)
tree60883532c86f70a713fc3af6a8584edeb044811b
parenta8d005f965dc66a05316db7bc723eaddbc5399ee (diff)
downloadAleeBot-2a8c799d7a9ad46f398c5e2feb448140eecbc638.tar.gz
AleeBot-2a8c799d7a9ad46f398c5e2feb448140eecbc638.tar.bz2
AleeBot-2a8c799d7a9ad46f398c5e2feb448140eecbc638.zip
Official 1.1.0 release!v1.1.0
Changelog: New command handler!
-rw-r--r--absettings.json.example7
-rw-r--r--aleebot.js281
-rw-r--r--commands/ask.js19
-rw-r--r--commands/attack.js9
-rw-r--r--commands/avatarurl.js4
-rw-r--r--commands/botinvite.js5
-rw-r--r--commands/eval.js59
-rw-r--r--commands/git.js4
-rw-r--r--commands/help.js34
-rw-r--r--commands/ping.js4
-rw-r--r--commands/say.js7
-rw-r--r--commands/serverinvite.js5
-rw-r--r--commands/ship.js4
-rw-r--r--commands/uptime.js41
-rw-r--r--commands/userinfo.js12
-rw-r--r--package.json15
16 files changed, 245 insertions, 265 deletions
diff --git a/absettings.json.example b/absettings.json.example
new file mode 100644
index 0000000..3d12948
--- /dev/null
+++ b/absettings.json.example
@@ -0,0 +1,7 @@
+{
+ "abtoken": "token",
+ "ownerID": "242775871059001344",
+ "prefix": "ab:",
+ "abversion": "1.1.0",
+ "year": "2017"
+}
diff --git a/aleebot.js b/aleebot.js
index f0ffcbc..ecfa4fa 100644
--- a/aleebot.js
+++ b/aleebot.js
@@ -25,22 +25,30 @@
**************************************/
const Discord = require('discord.js');
const blessed = require('blessed');
+const fs = require('fs');
const client = new Discord.Client();
const config = require('./absettings.json');
-var prefix = "ab:";
-const year = "2017";
-var abversion = "1.0.9";
+
var logsChannel = "318874545593384970";
client.on('ready', () => {
- console.log("[SUCCESS] AleeBot is now ready! Running version "+ abversion +"!");
- client.user.setGame(`with version ` + abversion);
- client.user.setStatus('online')
+ console.log("[SUCCESS] AleeBot is now ready! Running version "+ config.abversion +"!");
+ client.user.setGame(`with version ` + config.abversion);
+ 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));
+ });
});
-
/*
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);
@@ -79,12 +87,18 @@ client.on("guildDelete", guild => {
client.on("message", function(message){
if (message.author.bot) return;
if (message.channel.type === "dm") return;
- if (!message.content.startsWith(prefix)) return;
+ if(message.content.indexOf(config.prefix) !== 0) return;
- let command = message.content.split(" ")[0];
- command = command.slice(prefix.length);
+ 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);
+}
- let args = message.content.split(" ").slice(1);
/* if (wordFilter(message.content))
{
message.delete();
@@ -95,253 +109,8 @@ client.on("message", function(message){
message.author.send("You have been caught swearing in AleeArmy Community.");
} */
- if (command === 'help'){
- var embed = new Discord.RichEmbed()
- .setTitle(`Commands for AleeBot ` + abversion + ` and running on ${client.guilds.size} servers.`)
- .setDescription('Every command you put in this bot must start with '+ prefix)
- .addField('Fun Stuff:', 'attack\nask\nship',true)
- .addField('Info:', 'userinfo\nserverinfo',true)
- .addField('Link:', 'botinvite\nserverinvite\ngit',true)
- .addField('Owner Only:', 'say\neval',true)
- .addField('Monitor:', 'ping\nuptime',true)
- .addField('Etc:', 'avatarurl\nplan', true)
- .setFooter("AleeBot "+ abversion +" Copyright "+ year +". Created by Alee14", "https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048")
- .setColor("#7af442")
- message.channel.sendEmbed(embed);
-
- } /* This feature is broken
- else if {
- message.channel.send ("```Commands for AleeBot "+ abversion +".\nYou are using this view because this bot doesn't have permission to send embed link.\n\n" +
- ''+prefix+'avatarurl\n' +
- ''+prefix+'git\n' +
- ''+prefix+'ping\n' +
- ''+prefix+'suggest\n' +
- ''+prefix+'uptime\n' +
- ''+prefix+'userinfo\n' +
- ''+prefix+'serverinfo\n' +
- ''+prefix+'botinvite\n' +
- ''+prefix+'serverinvite\n' +
- ''+prefix+'plan\n' +
- ''+prefix+'attack\n' +
- ''+prefix+'ask\n' +
- ''+prefix+'ship\n\n' +
- "Copyright "+ year +". Created by Alee14\n```");
- } */
-
-
- if(command === 'avatarurl'){
- message.reply(message.author.avatarURL);
- }
-
- if(command === 'git'){
- message.channel.send ("Here's the github repo: https://github.com/AleeCorp/AleeBot");
- }
-
- if(command === 'ping'){
- message.reply("**PONG!** :ping_pong: " + Math.round(client.ping) + " ms");
- }
-
-
- if(command === 'uptime'){
- //This command was ported from AstralMod
- var timeString; // What we'll eventually put into the message
-
- var uptime = parseInt(client.uptime); // Get uptime in ms
-
- uptime = Math.floor(uptime / 1000); // Convert from ms to s
-
- var uptimeMinutes = Math.floor(uptime / 60); // Get the uptime in minutes
-
- var minutes = uptime % 60;
-
- var hours = 0;
-
- while (uptimeMinutes >= 60) {
-
- hours++;
-
- uptimeMinutes = uptimeMinutes - 60;
-
-}
-
-
-
-if (uptimeMinutes < 10) {
-
- timeString = hours + ":0" + uptimeMinutes // We need to add an additional 0 to the minutes
-
-} else {
-
- timeString = hours + ":" + uptimeMinutes // We don't need to add an extra 0.
-
-}
-
-
-
-message.reply(":clock1: AleeBot has been up for " + timeString + " hours.");
-
-commandProcessed = true;
- }
-
- if(command === 'userinfo'){ // This command was ported from Precipitation by OfficialRain
- var embed = new Discord.RichEmbed()
- .setAuthor(message.author.username, message.author.avatarURL)
- .setDescription("Here's some information about your user.")
- .addField("Names", "**Username:** " + message.author.username + "\n**Display Name:** " + message.member.displayName)
- .addField("Identity", "**User ID:** " + message.author.id + "\n**Discriminator:** " + message.author.discriminator)
- .addField("Create and Join Times", "**Created account at:** " + message.member.user.createdAt + "\n**Joined server at:** " + message.member.joinedAt)
- .setColor("#7af442")
- message.channel.sendEmbed(embed);
-
- }
-
- if(command === 'serverinfo'){
- var embed = new Discord.RichEmbed()
- .addField("Coming soon!")
- .setColor("#7af442")
- message.channel.sendEmbed(embed);
- }
-
- if (command === 'botinvite'){
- message.reply(':arrow_left: Continue in DMs.');
- message.author.sendMessage("AleeBot on your server? Great! Here's the link: https://goo.gl/KDQyrp");
- }
-
- if (command === 'serverinvite'){
- message.reply(':arrow_left: Continue in DMs.');
- message.author.sendMessage("You want a invite to the AleeArmy server? Here's the link: https://discord.gg/JqgXrAJ");
-
- }
-
- if(command === 'plan'){
- message.channel.send ('```Plans for future versions of AleeBot\n\n' +
- '1. Playing Music\n' +
- "If you want a suggestion go DM alee14.\n```");
- }
-
-
- if(command === 'attack'){
- //This command was ported from AstralMod
-
- if (command.indexOf("@everyone") == -1) {
-
- if (command.indexOf("@here") == -1) {
-
- message.channel.send("<@" + message.author.id + "> :right_facing_fist: " + args);
-
- } else {
-
- message.reply("Nice try, but I ain't going to interrupt everyone who is online at this time. Kinda nice to not be bothered.");
-
- }
-
- } else {
-
- message.reply("Nice try, but I ain't going to interrupt everyone. Kinda nice to not be bothered.");
-
- }
-
- commandProcessed = true;
- }
- if(command === 'ask'){
- var abaskanswer = [
- "Yes.",
- "Nope. Just kidding :P",
- "Definitely!",
- "No.",
- "Yep. Just kidding :P",
- "I doubt it.",
- "Maybe?",
- "I don't know?",
- "Hmm let me think :thinking:"
- ];
- if (args[1]) {
- message.channel.sendMessage(abaskanswer[Math.floor(Math.random() * abaskanswer.length)]);
- } else {
- message.channel.sendMessage("Sorry, I don't know what your saying.")
- }
-
- }
-// Owner is only allow to do this
- if(command === 'say'){
- if(message.author.id !== config.ownerID) return;
- message.channel.sendMessage(args.join(" "));
- message.delete();
-
- }
- if(command === 'eval'){
- if(message.author.id !== config.ownerID) return;
- const argseval = message.content.split(" ").slice(1);
- try {
- var code = argseval.join(" ");
- var evaled = eval(code);
-
- if (typeof evaled !== "string")
- evaled = require("util").inspect(evaled);
- message.delete();
-
- message.channel.send({
- embed: {
- color: 3191350,
- author: {
- name: "Eval is working!",
- icon_url: message.author.displayAvatarURL
- },
- fields: [{
- name: '**:inbox_tray: Input**',
- value: `\`\`\`js\n${code}\n\`\`\``
- },
- {
- name: '**:outbox_tray: Output**',
- value: `\`\`\`js\n${clean(evaled)}\n\`\`\``
- }
- ],
- }
- })
- } catch (err) {
- message.delete();
-
- message.channel.send({
- embed: {
- color: 3191350,
- author: {
- name: "Error",
- icon_url: message.author.displayAvatarURL
- },
- fields: [{
- name: '**Please check your code.**',
- value: `\`\`\`xl\n${clean(err)}\n\`\`\``
- },
- {
- name: '**Output**',
- value: `\`\`\`js\n${clean(evaled)}\n\`\`\``
- }
- ],
- }
- })
- }
- }
- if(command === 'ship'){
- message.channel.send(":ship: "+ message.author.username + " x " + message.guild.members.random().displayName);
- }
-
- try{
-
- }catch(err){
- message.channel.send(':no_entry_sign: Error: '+ err);
- console.log('[ERROR] '+ err)
- }
-
-
});
-const clean = text => {
- if (typeof(text) === "string")
- return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
- else
- return text;
-}
-
process.on('unhandledRejection', function(err, p) {
console.log("[ERROR | UNCAUGHT PROMISE] " + err.stack);
});
diff --git a/commands/ask.js b/commands/ask.js
new file mode 100644
index 0000000..a87cb8a
--- /dev/null
+++ b/commands/ask.js
@@ -0,0 +1,19 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+var abaskanswer = [
+ "Yes.",
+ "Nope. Just kidding :P",
+ "Definitely!",
+ "No.",
+ "Yep. Just kidding :P",
+ "I doubt it.",
+ "Maybe?",
+ "I don't know?",
+ "Hmm let me think :thinking:"
+];
+if (args[1]) {
+ message.channel.sendMessage(abaskanswer[Math.floor(Math.random() * abaskanswer.length)]);
+} else {
+ message.channel.sendMessage("Sorry, I don't know what your saying.")
+}
+}
diff --git a/commands/attack.js b/commands/attack.js
new file mode 100644
index 0000000..b17d0d9
--- /dev/null
+++ b/commands/attack.js
@@ -0,0 +1,9 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+ //This command was ported from AstralMod
+
+message.channel.send("<@" + message.author.id + "> :right_facing_fist: " + args);
+
+
+commandProcessed = true;
+}
diff --git a/commands/avatarurl.js b/commands/avatarurl.js
new file mode 100644
index 0000000..6cc4313
--- /dev/null
+++ b/commands/avatarurl.js
@@ -0,0 +1,4 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+message.reply(message.author.avatarURL);
+}
diff --git a/commands/botinvite.js b/commands/botinvite.js
new file mode 100644
index 0000000..32c85ba
--- /dev/null
+++ b/commands/botinvite.js
@@ -0,0 +1,5 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+message.reply(':arrow_left: Continue in DMs.');
+message.author.sendMessage("AleeBot on your server? Great! Here's the link: https://goo.gl/KDQyrp");
+}
diff --git a/commands/eval.js b/commands/eval.js
new file mode 100644
index 0000000..730def9
--- /dev/null
+++ b/commands/eval.js
@@ -0,0 +1,59 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+if(message.author.id !== config.ownerID) return;
+const clean = text => {
+ if (typeof(text) === "string")
+ return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
+ else
+ return text;
+}
+const argseval = message.content.split(" ").slice(1);
+ try {
+ var code = argseval.join(" ");
+ var evaled = eval(code);
+
+ if (typeof evaled !== "string")
+ evaled = require("util").inspect(evaled);
+ message.delete();
+
+ message.channel.send({
+ embed: {
+ color: 3191350,
+ author: {
+ name: "Eval is working!",
+ icon_url: message.author.displayAvatarURL
+ },
+ fields: [{
+ name: '**:inbox_tray: Input**',
+ value: `\`\`\`js\n${code}\n\`\`\``
+ },
+ {
+ name: '**:outbox_tray: Output**',
+ value: `\`\`\`js\n${clean(evaled)}\n\`\`\``
+ }
+ ],
+ }
+ })
+ } catch (err) {
+ message.delete();
+
+ message.channel.send({
+ embed: {
+ color: 3191350,
+ author: {
+ name: "Error",
+ icon_url: message.author.displayAvatarURL
+ },
+ fields: [{
+ name: '**Please check your code.**',
+ value: `\`\`\`xl\n${clean(err)}\n\`\`\``
+ },
+ {
+ name: '**Output**',
+ value: `\`\`\`js\n${clean(evaled)}\n\`\`\``
+ }
+ ],
+ }
+ })
+ }
+}
diff --git a/commands/git.js b/commands/git.js
new file mode 100644
index 0000000..c513d60
--- /dev/null
+++ b/commands/git.js
@@ -0,0 +1,4 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+ message.channel.send ("Here's the github repo: https://github.com/AleeCorp/AleeBot");
+}
diff --git a/commands/help.js b/commands/help.js
new file mode 100644
index 0000000..11c8073
--- /dev/null
+++ b/commands/help.js
@@ -0,0 +1,34 @@
+const Discord = require('discord.js');
+//const config = require('./absettings.json');
+//const abversion = require(config.abversion)
+exports.run = (client, message, args, config) => {
+
+var embed = new Discord.RichEmbed()
+ .setTitle(`Commands for AleeBot ` + config.abversion + ` and running on ${client.guilds.size} servers.`)
+ .setDescription('Every command you put in this bot must start with `ab:`')
+ .addField('Fun Stuff:', 'attack\nask\nship',true)
+ .addField('Info:', 'userinfo\nserverinfo',true)
+ .addField('Link:', 'botinvite\nserverinvite\ngit',true)
+ .addField('Owner Only:', 'say\neval',true)
+ .addField('Monitor:', 'ping\nuptime',true)
+ .addField('Etc:', 'avatarurl', true)
+ .setFooter("AleeBot "+ config.abversion +" Copyright "+ config.year +". Created by Alee14", "https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048")
+ .setColor("#7af442")
+ message.channel.sendEmbed(embed);
+} /* This feature is broken
+ else if {
+ message.channel.send ("```Commands for AleeBot "+ abversion +".\nYou are using this view because this bot doesn't have permission to send embed link.\n\n" +
+ ''+prefix+'avatarurl\n' +
+ ''+prefix+'git\n' +
+ ''+prefix+'ping\n' +
+ ''+prefix+'suggest\n' +
+ ''+prefix+'uptime\n' +
+ ''+prefix+'userinfo\n' +
+ ''+prefix+'serverinfo\n' +
+ ''+prefix+'botinvite\n' +
+ ''+prefix+'serverinvite\n' +
+ ''+prefix+'plan\n' +
+ ''+prefix+'attack\n' +
+ ''+prefix+'ask\n' +
+ ''+prefix+'ship\n\n' +
+ "Copyright "+ year +". Created by Alee14\n```"); */
diff --git a/commands/ping.js b/commands/ping.js
new file mode 100644
index 0000000..7291018
--- /dev/null
+++ b/commands/ping.js
@@ -0,0 +1,4 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+ message.reply("**PONG!** :ping_pong: " + Math.round(client.ping) + " ms");
+}
diff --git a/commands/say.js b/commands/say.js
new file mode 100644
index 0000000..6d395c6
--- /dev/null
+++ b/commands/say.js
@@ -0,0 +1,7 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+ if(message.author.id !== config.ownerID) return;
+ message.channel.sendMessage(args.join(" "));
+ message.delete();
+
+}
diff --git a/commands/serverinvite.js b/commands/serverinvite.js
new file mode 100644
index 0000000..cf0a696
--- /dev/null
+++ b/commands/serverinvite.js
@@ -0,0 +1,5 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+ message.reply(':arrow_left: Continue in DMs.');
+ message.author.sendMessage("You want a invite to the AleeArmy server? Here's the link: https://discord.gg/JqgXrAJ");
+}
diff --git a/commands/ship.js b/commands/ship.js
new file mode 100644
index 0000000..5ea5900
--- /dev/null
+++ b/commands/ship.js
@@ -0,0 +1,4 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+message.channel.send(":ship: "+ message.author.username + " x " + message.guild.members.random().displayName);
+}
diff --git a/commands/uptime.js b/commands/uptime.js
new file mode 100644
index 0000000..fd57a98
--- /dev/null
+++ b/commands/uptime.js
@@ -0,0 +1,41 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+//This command was ported from AstralMod
+var timeString; // What we'll eventually put into the message
+
+var uptime = parseInt(client.uptime); // Get uptime in ms
+
+uptime = Math.floor(uptime / 1000); // Convert from ms to s
+
+var uptimeMinutes = Math.floor(uptime / 60); // Get the uptime in minutes
+
+var minutes = uptime % 60;
+
+var hours = 0;
+
+while (uptimeMinutes >= 60) {
+
+hours++;
+
+uptimeMinutes = uptimeMinutes - 60;
+
+}
+
+
+
+if (uptimeMinutes < 10) {
+
+timeString = hours + ":0" + uptimeMinutes // We need to add an additional 0 to the minutes
+
+} else {
+
+timeString = hours + ":" + uptimeMinutes // We don't need to add an extra 0.
+
+}
+
+
+
+message.reply("AleeBot has been up for " + timeString + " hours. Looks like i'm not tired :wink:");
+
+commandProcessed = true;
+}
diff --git a/commands/userinfo.js b/commands/userinfo.js
new file mode 100644
index 0000000..2bb36fe
--- /dev/null
+++ b/commands/userinfo.js
@@ -0,0 +1,12 @@
+const Discord = require('discord.js');
+exports.run = (client, message, args, config) => {
+ var embed = new Discord.RichEmbed()
+ .setAuthor(message.author.username, message.author.avatarURL)
+ .setDescription("Here's your info.")
+ .addField("Names", "**Username:** " + message.author.username + "\n**Display Name:** " + message.member.displayName)
+ .addField("Identity", "**User ID:** " + message.author.id + "\n**Discriminator:** " + message.author.discriminator)
+ .addField("Create and Join Times", "**Created account at:** " + message.member.user.createdAt + "\n**Joined server at:** " + message.member.joinedAt)
+ .setColor("#7af442")
+ message.channel.sendEmbed(embed);
+
+}
diff --git a/package.json b/package.json
index ff7f661..30671c7 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,12 @@
{
"name": "aleebot",
- "version": "1.0.8.5",
- "description": "A chat bot for discord written in discord.js.",
+ "version": "1.1.0",
+ "description": "A chat bot for discord written in discord.js",
"main": "aleebot.js",
"dependencies": {
- "discord.js": "^11.1.0",
+ "blessed": "^0.1.81",
+ "fs": "^0.0.1-security",
+ "discord.js": "^11.1.0"
},
"devDependencies": {},
"scripts": {
@@ -14,12 +16,7 @@
"type": "git",
"url": "git+https://github.com/AleeCorp/AleeBot.git"
},
- "keywords": [
- "discord",
- "discord-bot",
- "javascript"
- ],
- "author": "AleeCorp",
+ "author": "alee14",
"license": "MIT",
"bugs": {
"url": "https://github.com/AleeCorp/AleeBot/issues"