-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.ts
37 lines (30 loc) · 1.2 KB
/
index.ts
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
import "dotenv/config";
import { Client, GatewayIntentBits } from "discord.js";
import loadEvents from "@/utils/loadEvents";
import { Logger } from "@/utils/logger";
Logger("event", "Starting SSH Bot session...");
Logger("info", `Running version v${process.env.npm_package_version} on Node.js ${process.version} on ${process.platform} ${process.arch}`);
Logger("info", "Check out the source code at https://github.com/igorkowalczyk/discord-ssh!");
Logger("info", "Don't forget to star the repository, it helps a lot!");
try {
const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: false,
},
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMembers | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
});
Logger("info", "Loading events...");
await loadEvents(client);
Logger("info", "Logging in...");
await client.login(process.env.TOKEN);
} catch (error) {
Logger("error", `Error starting the bot: ${error}`);
throw error;
}
process.on("unhandledRejection", (reason) => {
return Logger("error", `Unhandled Rejection: ${reason}`);
});
process.on("uncaughtException", (err) => {
return Logger("error", `Uncaught Exception: ${err}`);
});