blob: 174c401df551d392d0dda28ae97b2a56e81ee8ac [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001const logs = [
2 "channelUpdate",
3 "channelPinsUpdate",
4 "emojiUpdate",
5 "stickerUpdate",
6 "guildUpdate",
7 "guildMemberUpdate",
8 "guildMemberPunish",
9 "guildEventUpdate",
10 "guildEventMemberUpdate",
11 "guildRoleUpdate",
12 "guildInviteUpdate",
13 "messageUpdate",
14 "messageDelete",
15 "messageDeleteBulk",
16 "messageReactionUpdate",
17 "messagePing",
18 "messageMassPing",
19 "messageAnnounce",
20 "stageUpdate",
21 "threadUpdate",
22 "voiceStateUpdate",
23 "webhookUpdate"
24]
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 {
62 toHexInteger,
63 toHexArray,
64 tickets,
65 logs
66}