blob: a991918952f4c61c07b50a568936035b5f3913b4 [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001const logs = [
2 "channelUpdate",
pineafan6702cef2022-06-13 17:52:37 +01003 "channelPinsUpdate", // TODO
pineafan32767212022-03-14 21:27:39 +00004 "emojiUpdate",
pineafan6702cef2022-06-13 17:52:37 +01005 "stickerUpdate", // TODO
pineafan32767212022-03-14 21:27:39 +00006 "guildUpdate",
7 "guildMemberUpdate",
8 "guildMemberPunish",
pineafan32767212022-03-14 21:27:39 +00009 "guildRoleUpdate",
10 "guildInviteUpdate",
11 "messageUpdate",
12 "messageDelete",
13 "messageDeleteBulk",
14 "messageReactionUpdate",
15 "messagePing",
16 "messageMassPing",
pineafan6702cef2022-06-13 17:52:37 +010017 "messageAnnounce", // TODO
pineafan32767212022-03-14 21:27:39 +000018 "threadUpdate",
pineafanc6158ab2022-06-17 16:34:07 +010019 "webhookUpdate", // TODO
20 "guildMemberVerify", // TODO
21 "autoModeratorDeleted", // TODO
22 "nucleusSettingsUpdated", // TODO
23 ""
pineafan32767212022-03-14 21:27:39 +000024]
25
26const tickets = [
27 "support",
28 "report",
29 "question",
30 "issue",
31 "suggestion",
32 "other"
33]
34
35const toHexInteger = (permissions, array?) => {
36 if (!array) {
37 array = logs;
38 }
39 let int = 0n;
40
41 for(let perm of permissions) {
42 int += BigInt(2 ** array.indexOf(perm));
43 }
44 return int.toString(16)
45}
46
47const toHexArray = (permissionsHex, array?) => {
48 if (!array) {
49 array = logs;
50 }
51 let permissions = [];
52 let int = (BigInt("0x" + permissionsHex)).toString(2).split('').reverse();
53 for (let index in int) {
54 if (int[index] == "1") {
55 permissions.push(array[index]);
56 }
57 }
58 return permissions;
59}
60
61export {
pineafane625d782022-05-09 18:04:32 +010062 toHexInteger,
63 toHexArray,
pineafan32767212022-03-14 21:27:39 +000064 tickets,
65 logs
66}