1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/****************************************
*
* AleeBot: 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 economy = require('discord-eco');
const client = new Discord.Client();
const abVersion = '2.6.0';
const prefix = 'abb:';
const fs = require('fs');
const config = require('./absettings.json');
console.log('Welcome to AleeBot NodeJS Terminal!');
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
fs.readdir('./commands', (err, files) => {
if (err) console.error(err);
console.log(`[!] Attempting to load a total of ${files.length} commands into the memory.`);
files.forEach(file => {
try {
const command = require(`./commands/${file}`);
console.log(`[!] Attempting to load the command "${command.help.name}".`);
client.commands.set(command.help.name, command);
command.conf.aliases.forEach(alias => {
client.aliases.set(alias, command.help.name);
console.log(`[!] Attempting to load "${alias}" as an alias for "${command.help.name}"`);
});
}
catch (err) {
console.log('[X] An error has occured trying to load a command. Here is the error.');
console.log(err.stack);
}
});
console.log('[>] Command Loading complete!');
console.log('\n');
});
client.on('ready', () => {
console.log('[>] AleeBot is now ready!');
console.log('[i] Running version ' + abVersion + ` and in ${client.guilds.size} guilds`);
client.setInterval(function() {
const games = [
'AleeBot ' + abVersion + ' | ' + config.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 => {
console.log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
});
client.on('guildDelete', guild => {
console.log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`);
});
client.on('message', (msg) => {
if (msg.author.bot) return;
if (!msg.content.startsWith(prefix)) return;
const args = msg.content.slice(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) {
console.log("[X | UNCAUGHT PROMISE] " + err.stack);
});
client.login(config.abtoken).catch(function() {
console.log('[X] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com.');
});
|