-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
747 lines (673 loc) · 23.6 KB
/
utils.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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
import { MessageEmbed } from "discord.js";
import { PERSONALITY } from "../personality.js";
import { COMMONS } from "../commons.js";
import {
getAdminLogs,
removeAdminLogs,
removeBirthday,
removeIgnoredUser,
removeAlavirien,
} from "../helpers/index.js";
/**
* Fetch AuditLog from API.
* @param {Guild} guild Guild.
* @param {string} auditType String for audit type request.
* @param {number} limit Number of auditLogs fetched.
* @param {string} [type] String for audit type request.
* @returns {GuildAuditLogsEntry|null} Returns first auditLog entry or null if error.
*/
export const fetchAuditLog = async (guild, auditType, limit, type) => {
try {
const fetchedLogs = await guild.fetchAuditLogs({
limit: limit,
type: auditType,
}); //fetch logs
if (type === "list") return fetchedLogs.entries; //return all entries
return fetchedLogs.entries.first(); //return the first
} catch (e) {
//if no permission => crash
console.log("AuditLog Fetch Error", e);
return null;
}
};
/**
* Create and setup a MessageEmbed with common properties.
* @param {string} color The color of the embed.
* @param {object} personality The personality object of the embed.
* @param {object} [object] Object containing or not the author.
* @param {string} [type] Differentiate object use case.
* @returns {MessageEmbed} Embed with basic properties.
*/
export const setupEmbed = (color, personality, object, type) => {
const embed = new MessageEmbed()
.setColor(color)
.setTitle(personality.title)
.setTimestamp();
if (personality.description) embed.setDescription(personality.description);
if (type === "tag")
embed.addField(personality.author, object.toString(), true);
//add user as embed if required
else if (type === "skip") return embed;
//allows to skip the 3rd field
else if (type === "user")
embed.addField(personality.author, object.username, true);
//add user if required
else embed.addField(personality.author, object.name.toString(), true); //otherwise, add the object name as embed (for channels, roles, ...)
return embed;
};
/**
* Finish embeds and send them in the logChannel.
* @param {object} personalityEvent The personality related to the triggered event.
* @param {object} [executor] Object containing or not the executor, if any.
* @param {(MessageEmbed|MessageEmbed[])} embed Log embed, or array of embeds with log at index 0.
* @param {TextChannel} logChannel Log channel where to send embed.s.
* @param {string} [text] Additional text to add.
* @param {Attachment[]} [attachments] Message attachments.
* @returns {object[]}
*/
export const finishEmbed = async (
personalityEvent,
executor,
embed,
logChannel,
text,
attachments
) => {
const currentServer = COMMONS.getTest(); //get test data
if (
process.env.DEBUG === "no" &&
logChannel.guildId === currentServer.guildId
) {
//Ewibot detects test in test server => return
console.log("Ewibot log in Test server", personalityEvent.title);
return;
}
if (embed.author !== null) {
//if is an array, embed.author is undefined !== null
//if contains multiple embeds, the 1st is the log
if (personalityEvent.executor && executor !== null)
embed[0].addField(personalityEvent.executor, executor.toString(), true); //add the executor section
if (text) embed[0].addField(personalityEvent.text, text, false); //if any text (reason or content), add it
try {
const message = await logChannel.send({
embeds: embed,
allowed_mentions: { parse: [] },
}); //send
if (attachments && attachments.length !== 0) {
const gifMessage = await logChannel.send({ files: attachments }); //if attachments, send new message
return [message, gifMessage];
}
return [message];
} catch (e) {
console.log(
"finishEmbed list error\n",
personalityEvent.title,
new Date(),
e
);
}
return [];
}
if (personalityEvent.executor && executor !== null)
embed.addField(personalityEvent.executor, executor.toString(), true);
if (text) embed.addField(personalityEvent.text, text, false); //if any text (reason or content), add it
try {
const message = await logChannel.send({
embeds: [embed],
allowed_mentions: { parse: [] },
}); //send
if (attachments && attachments.length !== 0) {
const gifMessage = await logChannel.send({ files: attachments }); //if attachments, send new message
return [message, gifMessage];
}
return [message];
} catch (e) {
console.log("finishEmbed error\n", personalityEvent.title, e);
return [];
}
};
/**
* Differentiate finishEmbed cases.
* @param {object} obj Object related to listened event.
* @param {?object} log Audit log.
* @param {object} eventPerso Personality related to the listened event.
* @param {object} logPerso Audit log personality.
* @param {(MessageEmbed|MessageEmbed[])} embed Embed, or array of embeds with log at index 0.
* @param {TextChannel} logChannel Log channel where to send embed.s.
* @param {string} [text] Text to add when finishing the embed.
* @param {number} [diff] Timing difference between log and listener fire. If diff >= 5 log too old.
* @returns {object[]}
*/
export const endCasesEmbed = async (
object,
log,
eventPerso,
logPerso,
embed,
logChannel,
text,
diff
) => {
//if no AuditLog
if (diff >= 5) {
//if log too old
const messageList = await finishEmbed(
eventPerso,
logPerso.tooOld,
embed,
logChannel
);
return messageList;
}
if (!log) {
//if no AuditLog
const messageList = await finishEmbed(
eventPerso,
logPerso.noLog,
embed,
logChannel,
text
);
return messageList;
}
const { executor, target } = log;
if (target.id === object.id) {
//check if log report the correct kick
const messageList = await finishEmbed(
eventPerso,
executor,
embed,
logChannel,
text
);
return messageList;
} else {
//if bot or author executed the kick
const messageList = await finishEmbed(
eventPerso,
logPerso.noExec,
embed,
logChannel,
text
);
return messageList;
}
};
/**
* Handle basic admin log cases.
* @param {string} persoType Personnality type used for personalities fetch.
* @param {any} object Listener argument.
* @param {string} color Embed color.
* @param {string} logType AuditType for fetchAuditLog.
* @param {number} nb Number of log fetched in fetchAuditLog.
* @param {string} [objType] If object concerns a user, "user", nullable otherwise.
* @param {string} [embedType] If "tag", add obj as embed in the log embed.
* @param {boolean} [needReason] If true, get reason to add to the embed.
* @param {number} [diff] Timing difference between log and listener fire. If diff >= 5 log too old.
*/
export const generalEmbed = async (
persoType,
obj,
color,
logType,
nb,
objType,
embedType,
needReason,
diff
) => {
const personality = PERSONALITY.getAdmin(); //get personality
const perso = personality[persoType];
const aLog = personality.auditLog;
const channel = await getLogChannel(obj); //get logChannel
if (process.env.DEBUG === "no" && isTestServer(channel)) return; //if in prod && modif in test server
const objToSend = objType === "user" ? obj.user : obj; //handle user objects case
const embed = setupEmbed(color, perso, objToSend, embedType); //setup embed
const log = await fetchAuditLog(obj.guild, logType, nb); //get auditLog
const text = needReason ? log.reason : null; //if needed, get reason
endCasesEmbed(objToSend, log, perso, aLog, embed, channel, text, diff);
};
/**
* Fetch Log Channel.
* @param {object} eventObject Object given by listener event.
* @param {string} [type] String to ditinguish if returns channel or thread. "thread" for thread.
* @returns {TextChannel}
*/
export const getLogChannel = async (eventObject, type) => {
const currentServer = COMMONS.fetchGuildId(eventObject.guild.id); //get server local data
const id =
type === "thread" ? currentServer.logThreadId : currentServer.logChannelId;
return await eventObject.guild.channels.fetch(id); //return the log channel
};
export const clientEventUpdateProcess = (
client,
oldObj,
newObj,
personality,
logPerso,
logChannel,
embed,
type
) => {
//create timeout, store channels & timeout
//differentiate type
let obj;
let newData;
let timeout;
if (type === "channel") {
//get client data
const channelUpdate = client.channelUpdate;
obj = channelUpdate ? channelUpdate.channels : null;
//create timeout
timeout = setTimeout(
channelUpdateLog,
5000,
client,
personality,
logPerso,
logChannel,
embed
);
//setup new data
newData = {
id: newObj.id,
name: oldObj.name,
parentId: newObj.parentId,
};
} else if (type === "role") {
const roleUpdate = client.roleUpdate;
obj = roleUpdate ? roleUpdate.roles : null; //get data
//create timeout
timeout = setTimeout(
roleUpdateLog,
5000,
client,
personality,
logPerso,
logChannel,
embed
);
newData = { id: newObj.id, name: oldObj.name };
}
//initialise data to add to client
let updateData;
//check for identical obj
if (obj !== null && obj !== undefined) {
const names = obj.map((obj) => obj.name); //get all obj names
const index = names.findIndex((name) => name === oldObj.name); //find any doublon
if (index !== -1) {
//if any doublon
const precedent = obj[index]; //get precedent
newData.oldPos = precedent.oldPos; //keep precedent oldPosition
newData.newPos = newObj.rawPosition; //update newPosition
//remove doublon
const filtered = obj.filter((_obj, idx) => idx !== index);
if (type === "channel")
updateData = { channels: [...filtered, newData], timeout: timeout };
else if (type === "role")
updateData = { roles: [...filtered, newData], timeout: timeout };
} else {
//if no doublon
newData.oldPos = oldObj.rawPosition;
newData.newPos = newObj.rawPosition;
if (type === "channel")
updateData = { channels: [...obj, newData], timeout: timeout };
else if (type === "role")
updateData = { roles: [...obj, newData], timeout: timeout };
}
//store in client
if (type === "channel") client.channelUpdate = updateData;
else if (type === "role") client.roleUpdate = updateData;
} else {
//client not initialised or channels changes are too quick for client
newData.oldPos = oldObj.rawPosition;
newData.newPos = newObj.rawPosition;
if (type === "channel") {
updateData = { channels: [newData], timeout: timeout };
client.channelUpdate = updateData;
} else if (type === "role") {
updateData = { roles: [newData], timeout: timeout };
client.roleUpdate = updateData;
}
}
};
const channelUpdateLog = (client, chnUp, logPerso, logChannel, embed) => {
//Function called after channelUpdate timeout end
//client == {channels: [data], timeout: timeout}
//data == {id, name, parentId, oldPos, newPos}
const { channels } = client.channelUpdate;
//sort by parentId
const parentIdOrder = channels
.sort((a, b) => a.parentId - b.parentId)
.slice(); //sort channels with parentId
//regroup channels w/ same parent && sort parent channels
const oRegrouped = regroup(parentIdOrder, "oldPos");
const nRegrouped = regroup(parentIdOrder);
//create old/new channel order
const oldOrder = oRegrouped.list.reduce((acc, cur) => {
if (cur.length && cur.length > 1)
return [...acc, cur.sort((a, b) => a.oldPos - b.oldPos).slice()];
return [...acc, cur];
}, []); //sort channels with oldPosition
const newOrder = nRegrouped.list.reduce((acc, cur) => {
if (cur.length && cur.length > 1)
return [...acc, cur.sort((a, b) => a.newPos - b.newPos).slice()];
return [...acc, cur];
}, []); //slice() for variable shallow copy
//write text for embed
const oLen = oldOrder.length;
const oldText = oldOrder.reduce((acc, cur, idx) => {
//cur = [x*{name, id, parent, old, new}]
//write text for futur concatenation
const len = cur.length;
const lenNext = idx < oLen - 1 ? oldOrder[idx + 1].length : null;
const sep = lenNext !== null && lenNext !== 1 && len !== 1 ? `\n` : null;
const text = cur.reduce((acc, cur) => {
//get text from list
const name = removeEmote(cur.name); //remove the emote if any
const indent = cur.parentId ? ` ${name}` : name; //if has parent, ident
return [...acc, `\n${indent}`];
}, []);
if (sep !== null) return [...acc, ...text, sep];
return [...acc, ...text];
}, []);
const newText = newOrder.reduce((acc, cur, idx) => {
//write text for futur concatenation
//check length for separation
const len = cur.length;
const lenNext = idx < oLen - 1 ? newOrder[idx + 1].length : null;
const sep = lenNext !== null && lenNext !== 1 && len !== 1 ? "" : null;
const text = cur.reduce((acc, cur) => {
//get text from list
const name = removeEmote(cur.name); //remove the emote if any
const indent = cur.parentId ? ` ${name}` : name; //if has parent, ident
return [...acc, indent];
}, []);
if (sep !== null) return [...acc, ...text, sep];
return [...acc, ...text];
}, []);
console.log(
"channelLog position update\n",
"oldText",
oldText,
"newText",
newText
);
//delete duplicate channels not in bulk of changes
const isDuplicate = oldText.reduce((acc, cur, idx) => {
const nCur = newText[idx];
const o = cur.includes(" ") ? cur.split(" ")[2] : cur.slice(1);
const n = nCur.includes(" ") ? nCur.split(" ")[2] : nCur;
return [...acc, o === n];
}, []); //true if no change, false else
const first = isDuplicate.findIndex((bool) => !bool);
const last = isDuplicate.lastIndexOf(false) + 1;
const oText = oldText.slice(first, last);
const nText = newText.slice(first, last);
//check for empty modifs
if (oText.length === 0) {
finishEmbed(chnUp, logPerso.noLog, embed, logChannel, chnUp.noModifs); //send embed
return;
}
const space = 15;
const orderText = oText.reduce((acc, cur, idx) => {
const spaced = space2Strings(cur, nText[idx], space, " |");
if (idx === oText.length - 1) {
//if last one
return acc + spaced + "\n```"; //add end of code line code
}
return acc + spaced;
}, "```md\n" + space2Strings("avant", "apres", space, " |") + "\n");
finishEmbed(chnUp, logPerso.noLog, embed, logChannel, orderText); //send embed
client.channelUpdate = {}; //remove from client
};
const roleUpdateLog = (client, roleUp, logPerso, logChannel, embed) => {
//Function called after roleUpdate timeout end
//client == {roles: [data], timeout: timeout}
//data == {id, name, oldPos, newPos}
const { roles } = client.roleUpdate;
//change embed
embed.setTitle(roleUp.titleRoles); //change title
embed.setFields(embed.fields.slice(1)); //remove author field
//create old/new channel order
const oldSortedOrder = roles.sort((a, b) => b.oldPos - a.oldPos).slice(); //sort channels with oldPosition
const newSortedOrder = roles.sort((a, b) => b.newPos - a.newPos).slice();
//filter duplicate ids (same old/new position)
const filtered = oldSortedOrder.reduce(
(acc, cur, idx) => {
const newCur = newSortedOrder[idx];
//console.log("newCur", newCur.id, "cur.id", cur.id)
if (cur.id === newCur.id) return acc;
else
return {
oldOrder: [...acc.oldOrder, cur],
newOrder: [...acc.newOrder, newCur],
};
},
{ oldOrder: [], newOrder: [] }
);
if (filtered.oldOrder.length === 0) {
//if empty, no changes => return
finishEmbed(roleUp, logPerso.noLog, embed, logChannel, roleUp.noModifs); //send embed
return;
}
const { oldOrder, newOrder } = filtered;
const space = 15;
const orderText = oldOrder.reduce((acc, cur, idx) => {
const spaced = space2Strings(cur.name, newOrder[idx].name, space, " |");
if (idx === oldOrder.length - 1) {
//if last one
return acc + "\n" + spaced + "\n```"; //add end of code line code
}
return acc + "\n" + spaced;
}, "```md\n" + space2Strings("avant", "apres", space, " |") + "\n");
finishEmbed(roleUp, logPerso.noLog, embed, logChannel, orderText); //send embed
client.roleUpdate = {}; //remove from client
};
const space2Strings = (str1, str2, dist, sep) => {
//slice 2 strings, pad the end using dist + add a separator
const sliced1 = str1.startsWith("\n")
? str1.slice(0, dist + 1).padEnd(dist + 1, " ")
: str1.slice(0, dist).padEnd(dist, " ");
const sliced2 = str2.startsWith("\n")
? str2.slice(0, dist + 1).padEnd(dist + 1, " ")
: str2.slice(0, dist).padEnd(dist, " ");
return `${sliced1}${sep}${sliced2}`;
};
export const removeEmote = (str) => {
//remove emote from the begining of a string
let n = 0;
for (const char of str) {
const ascii = char.charCodeAt(0);
if (ascii > 255) n += char.length; //if not a standard char => emote
}
return str.slice(n);
};
const regroup = (element, type) => {
return element.reduce(
(acc, cur) => {
//regroup according to parentId
const list = acc.list; //get list
const len = list.length; //get list length
const lastParentId = acc.lastParentId; //get lastParentId
if (lastParentId === cur.parentId && cur.parentId !== null) {
//same parentId && not null : regroup
list[acc.lastAddIdx].push(cur);
return {
list: list,
lastParentId: lastParentId,
lastAddIdx: acc.lastAddIdx,
};
} else if (lastParentId !== cur.parentId && cur.parentId !== null) {
//new to place correctly :
const parentsIds = list.map((obj) => obj[0].id); //get all parent ids
const parentIdx = parentsIds.findIndex((id) => cur.parentId === id); //find parent index in list
if (parentIdx === -1) {
//no parent => new goup alone
return {
list: [...list, [cur]],
lastParentId: cur.parentId,
lastAddIdx: len,
};
}
//has parent
parentIdx === len - 1
? list.push([cur])
: list.splice(parentIdx + 1, 0, [cur]); //insert [cur]
return {
list: list,
lastParentId: cur.parentId,
lastAddIdx: parentIdx + 1,
};
}
//is a parent => sort with others
const parents = list.reduce((acc, cur) => {
if (cur.length === 1 && cur[0].parentId === null) {
if (type === "oldPos") return [...acc, cur[0].oldPos];
return [...acc, cur[0].newPos];
}
return [...acc, null]; //return null for index preservation
}, []); //[id, [], id, id, [], id]...
const parentIdx = parents.reduce((saved, now, indx) => {
//if is number && id < idToAdd => save index
const toCheck = type === "oldPos" ? cur.oldPos : cur.newPos;
if (typeof now === "number" && toCheck > now) return indx + 1;
return saved;
}, 0); //find parent index in list
list.splice(parentIdx, 0, [cur]);
return { list: list, lastParentId: cur.parentId, lastAddIdx: len };
},
{ list: [], lastParentId: null, lastAddIdx: 0 }
); //{list: [[{id, name, parentId, oldPos, newPos}, ...],], lastParentId
};
export const fetchMessage = async (message) => {
try {
return await message.fetch();
} catch (e) {
console.log(e);
return null;
}
};
/**
* Get strings corresponding to gif url.
* @param {string} content
* @returns {?string[]} If any, returns array of gif url strings.
*/
export const gifRecovery = (content) => {
const tenor = "tenor.com/";
const end = ".gif";
if (content.includes(tenor) || content.includes(end)) {
//if any gif inside content
const words = content.split(" "); //split content into words
const results = words.reduce((acc, cur) => {
//look for gif position in content
if (cur.includes(tenor) || cur.endsWith(end)) {
//if has link
const start = cur.indexOf("https://"); //look for link position
const sliced = start !== -1 ? cur.slice(start) : cur; //slice start of link
return [...acc, sliced]; //return link
}
return acc;
}, []);
return results;
}
return null;
};
export const logsRemover = async (client) => {
console.log("logsRemover");
const db = client.db;
const server =
process.env.DEBUG === "yes" ? COMMONS.getTest() : COMMONS.getProd();
// frequent logs remove
let type = "frequent"; //differentiate process for "frequent" and "userAD" logs
const dbData = getAdminLogs(db);
let data = dbData[type][0]; //get corresponding data
if (data.length !== 0) {
const threadChannel = await client.channels.fetch(server.logThreadId);
const result = await threadChannel.bulkDelete(data); //bulkDelete and get ids where it was okay
const diff = data.reduce((acc, cur) => {
if (result.has(cur)) return acc; //if no diff
else return [...acc, cur];
}, []); //find diff for error check
console.log("frequent diff", diff); //log for debug
}
removeAdminLogs(db, type); //remove from db
// userAD logs remove
type = "userAD";
data = dbData[type][0];
if (data.length !== 0) {
const logChannel = await client.channels.fetch(server.logChannelId);
const result = await logChannel.bulkDelete(data);
const diff = data.reduce((acc, cur) => {
if (result.has(cur)) return acc; //if no diff
else return [...acc, cur];
}, []); //find diff for error check
console.log("userAD diff", diff); //log for debug
}
removeAdminLogs(db, type); //remove from db
};
export const initAdminLogClearing = (client, waitingTime) => {
setTimeout(
() => {
logsRemover(client);
setInterval(
() => {
logsRemover(client);
},
24 * 3600 * 1000,
client
);
},
waitingTime,
client
);
};
export const octagonalLog = async (object, user) => {
//get personality
const personality = PERSONALITY.getAdmin();
const octaPerso = personality.octagonalSign;
let message = user ? object.message : object;
if (message.partial) await message.fetch();
//basic operations
const logChannel = await getLogChannel(message); //get logChannelId
const embed = setupEmbed(
"LUMINOUS_VIVID_PINK",
octaPerso,
message.author,
"tag"
); //setup embed
//add more info to embed
const executor = user
? await message.guild.members.fetch(user.id)
: object.author; //get executor
const date = message.createdAt.toString().slice(4, 24);
embed.addFields(
{ name: octaPerso.date, value: `${date}`, inline: true }, //date of message creation
{ name: octaPerso.channel, value: `<#${message.channelId}>`, inline: true }, //message channel
{ name: octaPerso.text, value: message.content }, //message content
{ name: octaPerso.executor, value: executor.toString(), inline: true }, //emote sent by
{
name: octaPerso.linkName,
value: `[${octaPerso.linkMessage}](${message.url})`,
inline: true,
} //get message link
);
finishEmbed(octaPerso, null, embed, logChannel);
};
/**
* Check if is currently in test server
* @param {Object} logChannel LogChannel retrieved from currentServer
* @returns True if is test server
*/
export const isTestServer = (logChannel) => {
const server = COMMONS.getTest();
const channels = [server.logChannelId, server.logThreadId];
return channels.includes(logChannel.id); //if test, return true
};
export const checkDB = (userId, client) => {
//check if user is in db for removal
const db = client.db;
removeBirthday(db, userId);
removeIgnoredUser(db, userId);
removeAlavirien(db, userId);
};