blob: 8badc581d2f7d31101e86491a719c7c728d26802 [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",
20 "nucleusSettingsUpdated",
21 "ticketUpdate"
pineafan32767212022-03-14 21:27:39 +000022]
23
24const tickets = [
25 "support",
26 "report",
27 "question",
28 "issue",
29 "suggestion",
30 "other"
31]
32
33const toHexInteger = (permissions, array?) => {
34 if (!array) {
35 array = logs;
36 }
37 let int = 0n;
38
39 for(let perm of permissions) {
40 int += BigInt(2 ** array.indexOf(perm));
41 }
42 return int.toString(16)
43}
44
45const toHexArray = (permissionsHex, array?) => {
46 if (!array) {
47 array = logs;
48 }
49 let permissions = [];
50 let int = (BigInt("0x" + permissionsHex)).toString(2).split('').reverse();
51 for (let index in int) {
pineafane23c4ec2022-07-27 21:56:27 +010052 if (int[index] === "1" && array.length > index) {
pineafan32767212022-03-14 21:27:39 +000053 permissions.push(array[index]);
54 }
55 }
56 return permissions;
57}
58
59export {
pineafane625d782022-05-09 18:04:32 +010060 toHexInteger,
61 toHexArray,
pineafan32767212022-03-14 21:27:39 +000062 tickets,
63 logs
64}