-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.js
37 lines (28 loc) · 1.1 KB
/
client.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
// Dependencies
const { Client, Collection, Intents } = require('discord.js');
const fs = require('fs');
const log4js = require('log4js');
// Configuration
const { activity } = require('./config/config.json');
const { token } = require('./config/secrets.json');
const loggingConfig = require('./config/logging.json');
// Global Configuration
log4js.configure(loggingConfig);
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const logger = log4js.getLogger('bot');
// Bot Setup
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
}
require('./events.js')(client);
client.once('ready', () => {
logger.info(`Logged in as ${client.user.tag}!`);
setInterval(() => {
const idx = Math.floor(Math.random() * activity.activities.length);
client.user.setActivity(activity.activities[idx].text, activity.activities[idx].options);
}, activity.updateInterval * 1000);
});
client.login(token);