-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (50 loc) · 2.18 KB
/
index.js
File metadata and controls
59 lines (50 loc) · 2.18 KB
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
const { getConfig, TaskManager, query } = require("raraph84-lib");
const { createPool } = require("mysql");
const { Client } = require("discord.js");
const { pushUsers } = require("./src/service");
const { check } = require("./src/commands/avertissement");
const { checkAbsences } = require("./src/commands/absence");
const config = getConfig(__dirname);
const tasks = new TaskManager();
const database = createPool({ ...config.database, charset: "utf8mb4_general_ci" });
tasks.addTask((resolve, reject) => {
query(database, "SELECT 1").then(() => {
console.log("Database connected");
resolve();
}).catch((error) => {
console.error("Database connection error", error);
reject();
});
}, (resolve) => database.end(() => resolve()));
console.log("Connecting to the database...");
const bot = new Client({ intents: ["Guilds", "GuildMembers", "GuildPresences", "GuildMessageReactions", "GuildMessages", "MessageContent"] });
bot.setMaxListeners(30);
bot.on("ready", async () => {
pushUsers(bot);
check(bot, database);
checkAbsences(bot, database);
require("./src/candidature").start(bot, database);
require("./src/DossierPatient").start(bot, database);
require("./src/guildJoinEvent").run(bot, database);
require("./src/organigrame").start(bot);
require("./src/permissions-ems").start(bot);
require("./src/PPAform").start(bot, database);
require("./src/presence").start(bot);
require("./src/service").start(bot);
require("./src/registerSlashCommands").start(bot, database);
require("./src/threadAutoJoiner").start(bot);
require("./src/tikcetsPsycologie").start(bot, database);
// require("./src/ticketsDirection").start(bot, database);
(await bot.channels.fetch(config.startMessageChannelId)).send({ content: ":white_check_mark: **Démarrage du bot !**" })
});
tasks.addTask((resolve, reject) => {
console.log("Connecting to the bot...");
bot.login(config.token).then(() => {
console.log("Connected to the bot");
resolve();
}).catch((error) => {
console.error("Bot connection error", error);
reject();
});
}, (resolve) => bot.destroy().then(() => resolve()));
tasks.run();