-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
57 lines (48 loc) · 1.4 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Client, ClientEvents, Intents } from "discord.js";
import server from "./server";
import cmd from "./command";
import dotenv from "dotenv";
import PrismaClient from "./prisma/client";
dotenv.config();
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
],
partials: [
"MESSAGE",
"CHANNEL",
"REACTION"
]
});
async function main() {
const events: string[] = [
"messageCreate",
"threadCreate",
"messageReactionAdd",
];
for (const event of events) {
client.on(
event,
(eventObject: ClientEvents) => cmd.handleEvents(event, eventObject)
);
}
client.on("ready", (client: Client) => {
const user = client.user;
console.log(`Forumify has been logged in as ${user?.username} (${user?.tag})!`);
});
client.on("error", (error: Error) => {
console.error("Unexpected error while logging into Discord.");
console.error(error);
return;
});
client.login(process.env.DC_TOKEN);
server.startServer();
}
main()
.catch(e => console.error(e))
.finally(async () => { await PrismaClient.$disconnect(); });