forked from Simpleboy353/REAPER-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
94 lines (83 loc) · 2.74 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const fs = require("fs");
const chalk = require("chalk");
const { Client, Collection, GatewayIntentBits, EmbedBuilder } = require("discord.js");
const { DEFAULT_PREFIX, BOT_TOKEN, ERROR_LOGS_CHANNEL, YT_COOKIE } = require("./config.json");
const { loadCommands } = require("./handler/loadCommands");
const { loadEvents } = require("./handler/loadEvents");
const { loadSlashCommands } = require("./handler/loadSlashCommands")
const { loadPlayerEvents } = require("./handler/loadPlayerEvents");
const { DiscordTogether } = require('discord-together');
const { Player } = require('discord-player');
const Enmap = require("enmap");
const client = new Client({
allowedMentions: { parse: ["users", "roles"] },
intents: 47007
});
const { checkValid } = require("./functions/validation/checkValid");
const Embeds = require("./functions/embeds/Embeds");
const Logger = require("./functions/Logger/Logger");
const Util = require("./functions/util/Util");
client.discordTogether = new DiscordTogether(client);
client.commands = new Collection();
client.slash = new Collection();
client.aliases = new Collection();
client.categories = fs.readdirSync("./Commands/");
client.setMaxListeners(0);
const Cookie = YT_COOKIE;
client.logger = Logger;
client.utils = Util;
client.say = Embeds;
const player = new Player(client, {
leaveOnEnd: true,
leaveOnStop: true,
leaveOnEmpty: false,
leaveOnEmptyCooldown: 60000,
autoSelfDeaf: true,
initialVolume: 130,
ytdlDownloadOptions: {
requestOptions: {
headers: {
cookie: Cookie,
}
}
},
});
client.player = player;
client.db = new Enmap({ name: "musicdb" });
loadCommands(client);
loadEvents(client);
loadPlayerEvents(client);
loadSlashCommands(client);
checkValid();
// Error Handling
process.on("uncaughtException", (err) => {
console.log("Uncaught Exception: " + err);
const exceptionembed = new EmbedBuilder()
.setTitle("Uncaught Exception")
.setDescription(`${err}`)
.setColor("Red")
client.channels.cache.get(ERROR_LOGS_CHANNEL).send({ embeds: [exceptionembed] })
});
process.on("unhandledRejection", (reason, promise) => {
console.log(
"[FATAL] Possibly Unhandled Rejection at: Promise ",
promise,
" reason: ",
reason.message
);
const rejectionembed = new EmbedBuilder()
.setTitle("Unhandled Promise Rejection")
.addFields([
{ name: "Promise", value: `${promise}` },
{ name: "Reason", value: `${reason.message}` },
])
.setColor("Red")
client.channels.cache.get(ERROR_LOGS_CHANNEL).send({ embeds: [rejectionembed] })
});
client.login(BOT_TOKEN).then(() => {
console.log(
chalk.bgBlueBright.black(
` Successfully logged in as: ${client.user.tag}`
)
);
});