-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
62 lines (55 loc) · 1.86 KB
/
bot.js
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
// require('./server');
require('colors');
require('dotenv').config();
const config = require('./config/config');
const {
Client,
Collection
} = require('eris');
const client = new Client(config.token, {
restMode: true,
intents: ['all']
});
const glob = require('glob');
client.commands = new Collection();
client.aliases = new Collection();
glob(__dirname + '/commands/*/*.js', function(er, files) {
if(er) console.log(er);
files.forEach(f => {
let props = require(`${f.replace('.js', '')}`);
client.commands.set(props.help.name, props);
props.help.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
});
console.log('[COMANDOS] Carregados com sucesso'.brightCyan);
});
client.on('ready', () => {
console.log(`[LOGIN] Pronto em ${client.user.username}#${client.user.discriminator} (${client.user.id})`.green);
client.editStatus('dnd', {
game: client.user.username,
name: 'Encontre Bots para seu servidor!',
type: 5
});
});
client.on('messageCreate', async message => {
if (message.author.bot) return;
if (message.content === `<@${client.user.id}>` || message.content === `<@!${client.user.id}>`) {
message.channel.createMessage(`🏓 ${message.author.mention} **|** Olá, meu prefixo é \`${config.prefix[0]}\`!`);
}
const regexPrefix = new RegExp(`^(${config.prefix.map(prefix => prefix.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')).join('|')}|<@!?${client.user.id}>)( )*`, 'gi');
if (!message.content.match(regexPrefix)) return;
const args = message.content.replace(regexPrefix, '').trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
const prefix = regexPrefix;
let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
if (!command) return;
if(command.help.status === 'off') return;
if (command) {
command.run(client, message, args, prefix);
}
else {
console.log();
}
});
client.connect();