blob: 6d0c55facb029cd76b04d68e33789fe2bafa9ee2 [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"
pineafan63fc5e22022-08-04 22:04:10 +010022];
pineafan32767212022-03-14 21:27:39 +000023
24const tickets = [
25 "support",
26 "report",
27 "question",
28 "issue",
29 "suggestion",
30 "other"
pineafan63fc5e22022-08-04 22:04:10 +010031];
pineafan32767212022-03-14 21:27:39 +000032
33const toHexInteger = (permissions, array?) => {
34 if (!array) {
35 array = logs;
36 }
37 let int = 0n;
38
Skyler Grey75ea9172022-08-06 10:22:23 +010039 for (const perm of permissions) {
pineafan32767212022-03-14 21:27:39 +000040 int += BigInt(2 ** array.indexOf(perm));
41 }
pineafan63fc5e22022-08-04 22:04:10 +010042 return int.toString(16);
43};
pineafan32767212022-03-14 21:27:39 +000044
45const toHexArray = (permissionsHex, array?) => {
46 if (!array) {
47 array = logs;
48 }
pineafan63fc5e22022-08-04 22:04:10 +010049 const permissions = [];
Skyler Grey75ea9172022-08-06 10:22:23 +010050 const int = BigInt("0x" + permissionsHex)
51 .toString(2)
52 .split("")
53 .reverse();
pineafan63fc5e22022-08-04 22:04:10 +010054 for (const index in int) {
pineafane23c4ec2022-07-27 21:56:27 +010055 if (int[index] === "1" && array.length > index) {
pineafan32767212022-03-14 21:27:39 +000056 permissions.push(array[index]);
57 }
58 }
59 return permissions;
pineafan63fc5e22022-08-04 22:04:10 +010060};
pineafan32767212022-03-14 21:27:39 +000061
Skyler Grey75ea9172022-08-06 10:22:23 +010062export { toHexInteger, toHexArray, tickets, logs };