-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (26 loc) · 778 Bytes
/
index.js
File metadata and controls
32 lines (26 loc) · 778 Bytes
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
const { Telegraf } = require("telegraf");
const fs = require("fs");
const config = require("./config.js");
let token = config["Bot"]["Token"];
const client = new Telegraf(token);
let path = "./commands/";
fs.readdirSync(path).forEach(function (file) {
if (file.endsWith(".js")) {
client.use(require(path + file));
}
});
client.telegram.getMe().then((bot) => {
console.log(`Bot started: @${bot.username}`);
});
process.on("unhandledRejection", (reason) => {
console.log(reason);
});
process.on("uncaughtException", (reason) => {
console.log(reason);
});
process.on("uncaughtExceptionMonitor", (reason) => {
console.log(reason);
});
client.launch();
process.once("SIGINT", () => client.stop("SIGINT"));
process.once("SIGTERM", () => client.stop("SIGTERM"));