-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
41 lines (31 loc) · 979 Bytes
/
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
import * as dotenv from "dotenv";
dotenv.config();
import "reflect-metadata";
import { Client } from "@typeit/discord";
import { logger } from "./utils/logger";
import { createConnection, getConnection } from "typeorm";
async function start() {
const client = new Client({
classes: [`${__dirname}/Bot.ts`, `${__dirname}/Bot.js`],
silent: false,
variablesChar: ":",
partials: ["MESSAGE", "CHANNEL", "REACTION"],
});
console.info("Try login discord...");
await client.login(process.env.DISCORD_BOT_TOKEN);
try {
console.info("Try connectoin database...");
await createConnection();
} catch (error) {
console.error("Database connectoin error...");
process.exit();
}
logger.info("Welcome to TDU21-Discord Bot...");
process.on("SIGINT", async () => {
logger.info("Shutdown TDU21-Discord Bot...");
await getConnection().close();
logger.info("Close database connectoin...");
client.destroy();
});
}
start();