-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
67 lines (58 loc) · 1.83 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
65
66
67
const { Client, Partials, Collection, GatewayIntentBits } = require('discord.js');
const config = require('./config/config');
// Creating a new client:
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel,
Partials.Message,
Partials.User,
Partials.GuildMember,
Partials.Reaction
],
presence: {
activities: [{
name: "FINAL FANTASY XIV",
type: 1
}],
status: 'dnd'
}
});
// Host the bot:
require('http').createServer((req, res) => res.end('Ready.')).listen(3000);
// Getting the bot token:
const AuthenticationToken = process.env.TOKEN || config.Client.TOKEN;
if (!AuthenticationToken) {
console.warn("[CRASH] Authentication Token for Discord bot is required! Use Envrionment Secrets or config.js.".red)
return process.exit();
};
// Handler:
client.prefix_commands = new Collection();
client.slash_commands = new Collection();
client.user_commands = new Collection();
client.message_commands = new Collection();
client.modals = new Collection();
client.events = new Collection();
module.exports = client;
["prefix", "application_commands", "modals", "events", "mongoose"].forEach((file) => {
require(`./handlers/${file}`)(client, config);
});
// Login to the bot:
client.login(AuthenticationToken)
.catch((err) => {
console.error("[CRASH] Something went wrong while connecting to your bot...");
console.error("[CRASH] Error from Discord API:" + err);
return process.exit();
});
// Handle errors:
process.on('unhandledRejection', async (err, promise) => {
console.error(`[ANTI-CRASH] Unhandled Rejection: ${err}`.red);
console.error(promise);
});