-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
51 lines (44 loc) · 1.43 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
const CommandoClient = require('./client');
const path = require('path');
const fs = require('fs')
const dotenv = require('dotenv')
const envConfig = dotenv.parse(fs.readFileSync('.env'))
for (const k in envConfig) {
process.env[k] = envConfig[k]
}
const client = new CommandoClient({
commandPrefix: '?',
owner: process.env.BOT_OWNER_ID,
disableMentions: 'everyone',
presence: {
activity: {
name: `?help | mTxServ.com`, // message de présence
type: 'LISTENING' // type d'activité
}
}
});
fs.readdir('./events/', (err, files) => {
if (err) return console.error(err);
files.forEach((file) => {
const eventFunction = require(`./events/${file}`);
if (eventFunction.disabled) return;
const event = eventFunction.event || file.split('.')[0];
const emitter = (typeof eventFunction.emitter === 'string' ? client[eventFunction.emitter] : eventFunction.emitter) || client;
const { once } = eventFunction;
try {
emitter[once ? 'once' : 'on'](event, (...args) => eventFunction.run(client, ...args));
} catch (error) {
console.error(error.stack);
}
});
});
client.registry
.registerDefaultTypes()
.registerGroups([
['divers', 'Divers'],
['admin', 'Admin'],
['bot', 'Bot'],
])
.registerCommandsIn(path.join(__dirname, 'commands'))
;
client.login(process.env.BOT_TOKEN);