-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (51 loc) · 2.07 KB
/
index.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
63
64
console.log("Starting bot!")
const fs = require('fs');
const Discord = require('discord.js');
const config = require('./config.js');
const client = new Discord.Client(config.discordjs);
client.config = config
const emoji = require('./util/emoji.js')
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
command.client = client;
client.commands.set(command.command.name, command);
}
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
const errorMsg = {
content: emoji("crash") + " There was an error executing the command. Please send the error and what you did to the bot owner: " + error,
ephemeral: true
}
if (interaction.replied) {
await interaction.followUp(errorMsg);
} else {
await interaction.reply(errorMsg);
}
}
});
client.data = require('./util/data.js');
client.data.promise = client.data.init()
// Different modules of the bot
client.dtune = require('dtune'); // Dev package please remember to put back before push
client.trackCreator = require('dtune/trackCreator.js'); // Dev package
client.dtuneChecks = require('dtune/userCheck.js'); // Dev package
client.autoplay = require('./util/autoplay.js')(client, client.data, client.dtune); // Disabled until bot is usable again
client.dtuneAnnouncer = require('./util/announcer.js')(client, client.dtune);
client.cli = require('./util/cli.js')(client);
client.once('ready', () => {
client.cli.startCLI();
//client.dashboard = require('./Stache/dashboard')(client, client.dtune, client.data); // Disabled until bot is usable again
console.log("Type help for available commands")
});
client.login(config.tokens.discord);