blob: 8a297b989189ab74a517ea79f5305dd65c0e08d2 [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",
pineafan6702cef2022-06-13 17:52:37 +01009 "guildEventUpdate", // TODO
10 "guildEventMemberUpdate", // TODO
pineafan32767212022-03-14 21:27:39 +000011 "guildRoleUpdate",
12 "guildInviteUpdate",
13 "messageUpdate",
14 "messageDelete",
15 "messageDeleteBulk",
16 "messageReactionUpdate",
17 "messagePing",
18 "messageMassPing",
pineafan6702cef2022-06-13 17:52:37 +010019 "messageAnnounce", // TODO
pineafan32767212022-03-14 21:27:39 +000020 "stageUpdate",
21 "threadUpdate",
pineafan6702cef2022-06-13 17:52:37 +010022 "voiceStateUpdate", // TODO
23 "webhookUpdate" // TODO
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}