blob: fde1340df5ff1a0c7a919f26d709ff4d9019d434 [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001const logs = [
2 "channelUpdate",
pineafan32767212022-03-14 21:27:39 +00003 "emojiUpdate",
pineafanda6e5342022-07-03 10:03:16 +01004 "stickerUpdate",
pineafan32767212022-03-14 21:27:39 +00005 "guildUpdate",
6 "guildMemberUpdate",
7 "guildMemberPunish",
pineafan32767212022-03-14 21:27:39 +00008 "guildRoleUpdate",
9 "guildInviteUpdate",
10 "messageUpdate",
11 "messageDelete",
12 "messageDeleteBulk",
13 "messageReactionUpdate",
pineafan32767212022-03-14 21:27:39 +000014 "messageMassPing",
pineafanda6e5342022-07-03 10:03:16 +010015 "messageAnnounce",
pineafan32767212022-03-14 21:27:39 +000016 "threadUpdate",
pineafanda6e5342022-07-03 10:03:16 +010017 "webhookUpdate",
pineafan412beec2022-06-29 21:46:26 +010018 "guildMemberVerify",
pineafan73a7c4a2022-07-24 10:38:04 +010019 "autoModeratorDeleted",
TheCodedProf01cba762023-02-18 15:55:05 -050020 "ticketUpdate",
21 // "nucleusSettingsUpdated"
pineafan63fc5e22022-08-04 22:04:10 +010022];
pineafan32767212022-03-14 21:27:39 +000023
Skyler Grey11236ba2022-08-08 21:13:33 +010024const tickets = ["support", "report", "question", "issue", "suggestion", "other"];
pineafan32767212022-03-14 21:27:39 +000025
PineaFan0d06edc2023-01-17 22:10:31 +000026const toHexInteger = (permissions: string[], array?: string[]): string => {
TheCodedProf01cba762023-02-18 15:55:05 -050027 if (!array) { array = logs; }
pineafan32767212022-03-14 21:27:39 +000028 let int = 0n;
29
Skyler Grey75ea9172022-08-06 10:22:23 +010030 for (const perm of permissions) {
pineafan32767212022-03-14 21:27:39 +000031 int += BigInt(2 ** array.indexOf(perm));
32 }
pineafan63fc5e22022-08-04 22:04:10 +010033 return int.toString(16);
34};
pineafan32767212022-03-14 21:27:39 +000035
PineaFan0d06edc2023-01-17 22:10:31 +000036const toHexArray = (permissionsHex: string, array?: string[]): string[] => {
pineafan32767212022-03-14 21:27:39 +000037 if (!array) {
38 array = logs;
39 }
PineaFan0d06edc2023-01-17 22:10:31 +000040 const permissions: string[] = [];
Skyler Grey75ea9172022-08-06 10:22:23 +010041 const int = BigInt("0x" + permissionsHex)
42 .toString(2)
43 .split("")
44 .reverse();
pineafan63fc5e22022-08-04 22:04:10 +010045 for (const index in int) {
pineafan3a02ea32022-08-11 21:35:04 +010046 if (int[index] === "1" && array.length > parseInt(index)) {
PineaFan0d06edc2023-01-17 22:10:31 +000047 permissions.push(array[index]!);
pineafan32767212022-03-14 21:27:39 +000048 }
49 }
50 return permissions;
pineafan63fc5e22022-08-04 22:04:10 +010051};
pineafan32767212022-03-14 21:27:39 +000052
Skyler Grey75ea9172022-08-06 10:22:23 +010053export { toHexInteger, toHexArray, tickets, logs };