-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
517 lines (482 loc) · 23.3 KB
/
index.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
/////////////////////////////////////////////////////////////////
// TEST DE COMMENTAIRE POUR CHECK SI LE PULL DE 06H FONCTIONNE //
/////////////////////////////////////////////////////////////////
//File reading
const fs = require('node:fs');
const path = require('node:path');
//.env Init
const dotenv = require('dotenv');
dotenv.config();
//SQL init
const sql = require('./sql/config/config');
//Read console init
const readline = require('readline');
const readcmd = readline.createInterface({
input: process.stdin,
output: process.stdout
});
//Récup du logger
const logger = require('./modules/logger');
//Fonction pour attendre
const wait = require('node:timers/promises').setTimeout;
const emb = require('./modules/embeds');
const service = require('./modules/service');
let discordClient = null;
//Discord init
const { Client, GatewayIntentBits, Partials, Collection, Events, WebhookClient } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.GuildMessageReactions
],
partials: [
Partials.User,
Partials.Reaction,
Partials.Message
]
});
//Init des commandes Discord
client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandsFolders = fs.readdirSync(foldersPath);
for(const folder of commandsFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for(const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
logger.warn(`La commande ${filePath} n'a pas la partie "data" ou "execute" !`);
}
}
}
//Init des events Discord
client.on(Events.MessageCreate, async (message) => {
if(message.guildId == process.env.IRIS_PRIVATE_GUILD_ID) {
let IRIS_SERVICE_CHANNEL_ID = await sql.getChannel('IRIS_SERVICE_CHANNEL_ID');
if (IRIS_SERVICE_CHANNEL_ID[0] == null) {
IRIS_SERVICE_CHANNEL_ID = null;
} else {
IRIS_SERVICE_CHANNEL_ID = IRIS_SERVICE_CHANNEL_ID[0].id;
}
let IRIS_RADIO_CHANNEL_ID = await sql.getChannel('IRIS_RADIO_CHANNEL_ID');
if (IRIS_RADIO_CHANNEL_ID[0] == null) {
IRIS_RADIO_CHANNEL_ID = null;
} else {
IRIS_RADIO_CHANNEL_ID = IRIS_RADIO_CHANNEL_ID[0].id;
}
let IRIS_BCMS_BEDS_THREAD_ID = await sql.getChannel('bcms_beds_thread');
if (IRIS_BCMS_BEDS_THREAD_ID[0] == null) {
IRIS_BCMS_BEDS_THREAD_ID = null;
} else {
IRIS_BCMS_BEDS_THREAD_ID = IRIS_BCMS_BEDS_THREAD_ID[0].id;
}
let IRIS_WORKFORCE_CHANNEL_ID = await sql.getChannel('IRIS_WORKFORCE_CHANNEL_ID');
if (IRIS_WORKFORCE_CHANNEL_ID[0] == null) {
IRIS_WORKFORCE_CHANNEL_ID = null;
} else {
IRIS_WORKFORCE_CHANNEL_ID = IRIS_WORKFORCE_CHANNEL_ID[0].id;
}
let IRIS_FOLLOW_CHANNEL_ID = await sql.getChannel('follow');
if (IRIS_FOLLOW_CHANNEL_ID[0] == null) {
IRIS_FOLLOW_CHANNEL_ID = null;
} else {
IRIS_FOLLOW_CHANNEL_ID = IRIS_FOLLOW_CHANNEL_ID[0].id;
}
let IRIS_FOLLOW_THREAD_PPA_ID = await sql.getChannel('follow_thread_ppa');
if (IRIS_FOLLOW_THREAD_PPA_ID[0] == null) {
IRIS_FOLLOW_THREAD_PPA_ID = null;
} else {
IRIS_FOLLOW_THREAD_PPA_ID = IRIS_FOLLOW_THREAD_PPA_ID[0].id;
}
let IRIS_FOLLOW_THREAD_SECOURS_ID = await sql.getChannel('follow_thread_secours');
if (IRIS_FOLLOW_THREAD_SECOURS_ID[0] == null) {
IRIS_FOLLOW_THREAD_SECOURS_ID = null;
} else {
IRIS_FOLLOW_THREAD_SECOURS_ID = IRIS_FOLLOW_THREAD_SECOURS_ID[0].id;
}
let IRIS_TEMPLATE_FORM_CHANNEL_ID = await sql.getChannel('template_form');
if (IRIS_TEMPLATE_FORM_CHANNEL_ID[0] == null) {
IRIS_TEMPLATE_FORM_CHANNEL_ID = null;
} else {
IRIS_TEMPLATE_FORM_CHANNEL_ID = IRIS_TEMPLATE_FORM_CHANNEL_ID[0].id;
}
let IRIS_CFX_THREAD_ID = await sql.getChannel('cfx_thread');
if (IRIS_CFX_THREAD_ID[0] == null) {
IRIS_CFX_THREAD_ID = null;
} else {
IRIS_CFX_THREAD_ID = IRIS_CFX_THREAD_ID[0].id;
}
if (message.channelId == IRIS_SERVICE_CHANNEL_ID || message.channelId == IRIS_RADIO_CHANNEL_ID || message.channelId == IRIS_WORKFORCE_CHANNEL_ID || message.channelId == IRIS_FOLLOW_CHANNEL_ID || message.channelId == IRIS_FOLLOW_THREAD_PPA_ID || message.channelId == IRIS_FOLLOW_THREAD_SECOURS_ID || message.channelId == IRIS_TEMPLATE_FORM_CHANNEL_ID || message.channelId == IRIS_CFX_THREAD_ID) {
if(message.author != process.env.IRIS_DISCORD_ID) {
logger.warn(`${message.member.nickname} - ${message.author.username}#${message.author.discriminator} (<@${message.author.id}>)\n\nà envoyé un message dans le salon interdit "#${client.guilds.cache.get(message.guildId).channels.cache.get(message.channelId).name}" <#${message.channelId}>\n\nContenu: "${message.content}"`);
await message.delete();
}
}
if(message.channelId == IRIS_BCMS_BEDS_THREAD_ID) {
if(message.author != process.env.IRIS_DISCORD_ID) {
logger.warn(`${message.member.nickname} - ${message.author.username}#${message.author.discriminator} (<@${message.author.id}>)\n\nà envoyé un message dans le salon interdit "#${client.guilds.cache.get(message.guildId).channels.cache.get(message.channelId).name}" <#${message.channelId}>\n\nContenu: "${message.content}"`);
await message.delete();
const warnMsg = await message.channel.send({ content: `<@${message.member.id}>`, embeds: [emb.generate(`Oups :(`, null, `Vous ne pouvez pas écrire dans ce fil, si vous souhaitez utiliser la salle de réveil veuillez passer par la commande </lit:${process.env.IRIS_BEDS_COMMAND_ID}> pour ajouter un patient ou par les boutons pour en retirer !`, `#FF0000`, process.env.LSMS_LOGO_V2, null, `Gestion de la salle de réveil`, `https://cdn.discordapp.com/icons/${message.guild.id}/${message.guild.icon}.webp`, null, null, null, false)] });
await wait(8000);
await warnMsg.delete();
}
}
}
});
client.on(Events.MessageDelete, async (message) => {
if(message.type == 19 || message.type == 20) {
return;
}
if(message.author != null && message.author.id != process.env.IRIS_DISCORD_ID) {
return;
}
if(message.guildId == process.env.IRIS_PRIVATE_GUILD_ID) {
let IRIS_SERVICE_CHANNEL_ID = await sql.getChannel('IRIS_SERVICE_CHANNEL_ID');
if (IRIS_SERVICE_CHANNEL_ID[0] == null) {
IRIS_SERVICE_CHANNEL_ID = null;
} else {
IRIS_SERVICE_CHANNEL_ID = IRIS_SERVICE_CHANNEL_ID[0].id;
}
let IRIS_RADIO_CHANNEL_ID = await sql.getChannel('IRIS_RADIO_CHANNEL_ID');
if (IRIS_RADIO_CHANNEL_ID[0] == null) {
IRIS_RADIO_CHANNEL_ID = null;
} else {
IRIS_RADIO_CHANNEL_ID = IRIS_RADIO_CHANNEL_ID[0].id;
}
let IRIS_BCMS_BEDS_THREAD_ID = await sql.getChannel('bcms_beds_thread');
if (IRIS_BCMS_BEDS_THREAD_ID[0] == null) {
IRIS_BCMS_BEDS_THREAD_ID = null;
} else {
IRIS_BCMS_BEDS_THREAD_ID = IRIS_BCMS_BEDS_THREAD_ID[0].id;
}
let IRIS_WORKFORCE_CHANNEL_ID = await sql.getChannel('IRIS_WORKFORCE_CHANNEL_ID');
if (IRIS_WORKFORCE_CHANNEL_ID[0] == null) {
IRIS_WORKFORCE_CHANNEL_ID = null;
} else {
IRIS_WORKFORCE_CHANNEL_ID = IRIS_WORKFORCE_CHANNEL_ID[0].id;
}
let IRIS_AGENDA_CHANNEL_ID = await sql.getChannel('agenda');
if (IRIS_AGENDA_CHANNEL_ID[0] == null) {
IRIS_AGENDA_CHANNEL_ID = null;
} else {
IRIS_AGENDA_CHANNEL_ID = IRIS_AGENDA_CHANNEL_ID[0].id;
}
let IRIS_FOLLOW_CHANNEL_ID = await sql.getChannel('follow');
if (IRIS_FOLLOW_CHANNEL_ID[0] == null) {
IRIS_FOLLOW_CHANNEL_ID = null;
} else {
IRIS_FOLLOW_CHANNEL_ID = IRIS_FOLLOW_CHANNEL_ID[0].id;
}
let IRIS_FOLLOW_THREAD_PPA_ID = await sql.getChannel('follow_thread_ppa');
if (IRIS_FOLLOW_THREAD_PPA_ID[0] == null) {
IRIS_FOLLOW_THREAD_PPA_ID = null;
} else {
IRIS_FOLLOW_THREAD_PPA_ID = IRIS_FOLLOW_THREAD_PPA_ID[0].id;
}
let IRIS_FOLLOW_THREAD_SECOURS_ID = await sql.getChannel('follow_thread_secours');
if (IRIS_FOLLOW_THREAD_SECOURS_ID[0] == null) {
IRIS_FOLLOW_THREAD_SECOURS_ID = null;
} else {
IRIS_FOLLOW_THREAD_SECOURS_ID = IRIS_FOLLOW_THREAD_SECOURS_ID[0].id;
}
let IRIS_TEMPLATE_FORM_CHANNEL_ID = await sql.getChannel('template_form');
if (IRIS_TEMPLATE_FORM_CHANNEL_ID[0] == null) {
IRIS_TEMPLATE_FORM_CHANNEL_ID = null;
} else {
IRIS_TEMPLATE_FORM_CHANNEL_ID = IRIS_TEMPLATE_FORM_CHANNEL_ID[0].id;
}
let IRIS_CFX_THREAD_ID = await sql.getChannel('cfx_thread');
if (IRIS_CFX_THREAD_ID[0] == null) {
IRIS_CFX_THREAD_ID = null;
} else {
IRIS_CFX_THREAD_ID = IRIS_CFX_THREAD_ID[0].id;
}
switch(message.channelId) {
case IRIS_SERVICE_CHANNEL_ID:
service.regenService();
break;
case IRIS_RADIO_CHANNEL_ID:
service.regenCentrale();
break;
case IRIS_BCMS_BEDS_THREAD_ID:
service.regenBCMS();
break;
case IRIS_WORKFORCE_CHANNEL_ID:
service.regenDoctors();
break;
case IRIS_AGENDA_CHANNEL_ID:
service.regenAgenda();
break;
case IRIS_FOLLOW_CHANNEL_ID:
service.regenFollow();
break;
case IRIS_TEMPLATE_FORM_CHANNEL_ID:
service.regenTemplate();
break;
case IRIS_CFX_THREAD_ID:
service.regenCfx();
break;
default:
break;
}
}
if(message.guildId == process.env.IRIS_DEBUG_GUILD_ID) {
switch(message.channelId) {
case process.env.IRIS_MANAGEMENT_CHANNEL_ID:
service.regenManagement();
break;
default:
break;
}
}
logger.warn(`Message de ${message.author} supprimé dans le salon "#${client.guilds.cache.get(message.guildId).channels.cache.get(message.channelId).name}" <#${message.channelId}> du serveur "**${client.guilds.cache.get(message.guildId).name}**"\n\nContenu: "${message.content}"`);
});
client.on(Events.MessageReactionAdd, async (reaction, user) => {
if(discordClient != null) {
const message = reaction.message;
const doctorSql = require('./sql/doctorManagement/doctor');
const channel = await doctorSql.getDoctorChannelIDByChannel(message.channelId);
if(channel[0] != null) {
const msg = await discordClient.guilds.cache.get(process.env.IRIS_PRIVATE_GUILD_ID).channels.cache.get(message.channelId).messages.fetch(message.id);
if(msg.content != '- Terrain' && msg.content != '- Gestion' && msg.content != '- Enseignement' && msg.content != '- Formation complémentaire') {
if(message.embeds[0] != null) {
await reaction.remove();
return;
}
if(msg.author.id == process.env.IRIS_DISCORD_ID || msg.author.id == '692506221135265822') {
switch(reaction.emoji.name) {
case '✅':
message.reactions.cache.forEach((value) => {
if(value.emoji.name != '✅') {
value.remove();
}
});
return;
case '⏲️':
message.reactions.cache.forEach((value) => {
if(value.emoji.name != '⏲️') {
value.remove();
}
});
return;
case '❌':
message.reactions.cache.forEach((value) => {
if(value.emoji.name != '❌') {
value.remove();
}
});
return;
default:
await reaction.remove();
return;
}
}
}
}
}
});
client.on(Events.GuildScheduledEventCreate, async (guildScheduledEvent) => {
if(guildScheduledEvent.guildId == process.env.IRIS_PRIVATE_GUILD_ID) {
//Import du créateur de webhook
logger.log(`Événement "**${guildScheduledEvent.name}**" créé`);
const webhookClient = new WebhookClient({ url: process.env.IRIS_AGENDA_WEBHOOK_URL });
webhookClient.send({ content: `https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}` });
}
});
client.on(Events.GuildScheduledEventUpdate, async (guildScheduledEvent) => {
if(guildScheduledEvent.guildId == process.env.IRIS_PRIVATE_GUILD_ID) {
//Récup des requêtes SQL
const sqlAgenda = require('./sql/agenda/agenda');
const agendaChannelId = await sqlAgenda.getAgendaChannelId();
if(agendaChannelId[0] != null) {
if(guildScheduledEvent.status == 1) {
logger.log(`Événement "**${guildScheduledEvent.name}**" modifié/démarré`);
}
if(guildScheduledEvent.status == 2) {
logger.log(`Événement "**${guildScheduledEvent.name}**" terminé`);
guildScheduledEvent.guild.channels.cache.get(agendaChannelId[0].id).messages.fetch().then(m => { m.forEach(msg => { if(msg.content == `https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}`) { msg.delete(); } }) });
const isEventIsDelta = await sqlAgenda.getByURL(`https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}`);
if(isEventIsDelta[0] != null) {
await sqlAgenda.updateToEndState(`https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}`);
}
}
}
}
});
client.on(Events.GuildScheduledEventDelete, async (guildScheduledEvent) => {
if(guildScheduledEvent.guildId == process.env.IRIS_PRIVATE_GUILD_ID) {
//Récup des requêtes SQL
const sqlAgenda = require('./sql/agenda/agenda');
const agendaChannelId = await sqlAgenda.getAgendaChannelId();
if(agendaChannelId[0] != null) {
logger.log(`Événement "**${guildScheduledEvent.name}**" supprimé`);
guildScheduledEvent.guild.channels.cache.get(agendaChannelId[0].id).messages.fetch().then(m => { m.forEach(msg => { if(msg.content == `https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}`) { msg.delete(); } }) });
const isEventIsDelta = await sqlAgenda.getByURL(`https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}`);
if(isEventIsDelta[0] != null) {
await sqlAgenda.updateToEndState(`https://discord.com/events/${guildScheduledEvent.guildId}/${guildScheduledEvent.id}`);
}
}
}
});
client.on(Events.ClientReady, async (client) => {
discordClient = client;
//Récupération du module WebSocket
const WebSocket = require('./modules/commonRadioServer');
//Connection au serveur de radio communes
const ws = WebSocket.getWS();
//Récupération du module de création de JsonWebToken
const jwt = require('jsonwebtoken');
//Requêtes SQL de radios
const sqlRadio = require('./sql/radio/radios');
ws.on('error', (err) => { logger.error(err); });
WebSocket.askRadioInfo('lsms-lspd-lscs');
WebSocket.askRadioInfo('lsms-bcms');
ws.onmessage = async (wsData) => {
let data;
try { data = jwt.verify(wsData.data, process.env.RADIO_SERVER_JWT_SECRET); } catch (err) { logger.error(err); }
let radioMessageId;
try {
radioMessageId = await sqlRadio.getRadioMessageId();
radioMessageId = radioMessageId[0];
} catch(err) {
radioMessageId = null;
}
if(radioMessageId == null) {
await wait(10000);
updateRadios(client, ws, data, sqlRadio);
} else {
updateRadios(client, ws, data, sqlRadio);
}
}
});
const eventsPath = path.join(__dirname, 'events');
const eventsFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for(const file of eventsFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if(event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
//Mise en ligne du bot sur Discord
client.login(process.env.IRIS_DISCORD_TOKEN);
//Arrêt lors d'une commande console
readcmd.on('line', async (input) => {
if(input.toLowerCase() == 'quit') {
logger.log(`Au revoir! ${client.user.tag} hors-ligne`);
await client.destroy();
process.exit(0);
}
});
//Arrêt avec forever (utilisé sur le serveur de prod)
process.on('SIGTERM', async () => {
logger.log(`Au revoir! ${client.user.tag} hors-ligne`);
await client.destroy();
process.exit(0);
});
async function updateRadios(client, ws, data, sqlRadio) {
//Module de mise à jour des radios
const radio = require('./modules/changeRadio');
//Récup du service de kick
const userservice = require('./modules/kickservice');
const sqlBlackout = require('./sql/config/config');
try {
if (data.type === "refresh") {
// On radio refresh
if(data.radioName == 'lsms-lspd-lscs') {
radio.change(client, 'regenFDO', data.radioFreq, true, service.isBlackout());
await sqlRadio.setRadio('fdo', data.radioFreq);
}
if(data.radioName == 'lsms-bcms') {
radio.change(client, 'regenBCMS', data.radioFreq, true, service.isBlackout());
await sqlRadio.setRadio('bcms', data.radioFreq);
}
} else if(data.type === "auto_refresh") {
if(data.radioName == 'lsms-lspd-lscs') {
//Generation aléatoire de la radio entre 250.0 et 344.9
const freqUnit = Math.floor(Math.random() * (344-250+1)) + 250;
const freqDeci = Math.floor(Math.random() * 10);
const freqLSMS = freqUnit + '.' + freqDeci;
logger.logRadio('LSMS', freqLSMS);
service.resetRadios(client, freqLSMS, data.radioFreq, null);
const guild = client.guilds.cache.get(process.env.IRIS_PRIVATE_GUILD_ID);
await userservice.kick(guild, guild.members.cache.get(process.env.IRIS_DISCORD_ID), false);
//Remove doctors
const doctor = require('./sql/doctorManagement/doctor');
const doctorsToRemove = await doctor.getDoctorsToRemove();
if(doctorsToRemove[0] != null) {
for(let i=0;i<doctorsToRemove.length;i++) {
const currentDate = new Date();
const departureDate = new Date(doctorsToRemove[i].departure_date);
let monthToCheck = currentDate.getMonth();
if(departureDate.getMonth() == 11) {
monthToCheck = 0;
}
let timeToRemove = false;
if(departureDate.getMonth() == 11 && currentDate.getMonth() == 0 && currentDate.getFullYear() == departureDate.getFullYear() + 1 && currentDate.getDate() == departureDate.getDate()) {
timeToRemove = true;
} else if(departureDate.getMonth() == 0 && currentDate.getMonth() == 1 && currentDate.getFullYear() == departureDate.getFullYear() && currentDate.getDate() == departureDate.getDate()) {
timeToRemove = true
} else if(currentDate.getFullYear() == departureDate.getFullYear()) {
if(departureDate.getMonth() == 0 && currentDate.getMonth() == 2 && departureDate.getDate() > 28 && currentDate.getDate() == 1) {
timeToRemove = true;
} else if(departureDate.getMonth() == 1 || departureDate.getMonth() == 3 || departureDate.getMonth() == 5 || departureDate.getMonth() == 8 || departureDate.getMonth() == 10) {
if(currentDate.getDate() == departureDate.getDate() + 1) { timeToRemove = true; }
} else { if(currentDate.getDate() == departureDate.getDate()) { timeToRemove = true; } }
}
if(timeToRemove) {
try {
await guild.channels.cache.get(doctorsToRemove[i].channel_id).delete();
} catch (err) {}
await doctor.setDeleted(doctorsToRemove[i].id);
}
}
}
logger.log(`Reset de 06h00 effectué !`);
}
} else if (data.type === "radio_info") {
while(service.isGen()) {
await wait(1);
}
const getBlackoutMode = await sqlBlackout.getBlackoutMode();
//const wsModule = require('./modules/commonRadioServer');
// On connection and specific radio asking
if(getBlackoutMode[0].state == '1') {
service.setBlackout(true);
} else {
service.setBlackout(false);
}
if(data.radioName == 'lsms-lspd-lscs') {
radio.change(client, 'regenFDO', data.radioFreq, false, service.isBlackout());
await sqlRadio.setRadio('fdo', data.radioFreq);
}
if(data.radioName == 'lsms-bcms') {
const isBCMSDisplayed = await sqlRadio.isRadioDisplayed('bcms');
if(isBCMSDisplayed[0].displayed == '1') {
radio.change(client, 'regenBCMS', data.radioFreq, false, service.isBlackout());
}
await sqlRadio.setRadio('bcms', data.radioFreq);
}
} else if(data.type === "error") {
// If an error is returned
logger.error(data);
}
} catch {}
}
function isLeapYear(year) {
if ((0 == year % 4) && (0 != year % 100) || (0 == year % 400)) {
return true;
} else {
return false;
}
}