pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | const logs = [ |
| 2 | "channelUpdate", |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 3 | "emojiUpdate", |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 4 | "stickerUpdate", |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 5 | "guildUpdate", |
| 6 | "guildMemberUpdate", |
| 7 | "guildMemberPunish", |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 8 | "guildRoleUpdate", |
| 9 | "guildInviteUpdate", |
| 10 | "messageUpdate", |
| 11 | "messageDelete", |
| 12 | "messageDeleteBulk", |
| 13 | "messageReactionUpdate", |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 14 | "messageMassPing", |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 15 | "messageAnnounce", |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 16 | "threadUpdate", |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 17 | "webhookUpdate", |
pineafan | 412beec | 2022-06-29 21:46:26 +0100 | [diff] [blame] | 18 | "guildMemberVerify", |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 19 | "autoModeratorDeleted", |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame] | 20 | "ticketUpdate", |
| 21 | // "nucleusSettingsUpdated" |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 22 | ]; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 23 | |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 24 | const tickets = ["support", "report", "question", "issue", "suggestion", "other"]; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 25 | |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 26 | const toHexInteger = (permissions: string[], array?: string[]): string => { |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame] | 27 | if (!array) { array = logs; } |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 28 | let int = 0n; |
| 29 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 30 | for (const perm of permissions) { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 31 | int += BigInt(2 ** array.indexOf(perm)); |
| 32 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 33 | return int.toString(16); |
| 34 | }; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 35 | |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 36 | const toHexArray = (permissionsHex: string, array?: string[]): string[] => { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 37 | if (!array) { |
| 38 | array = logs; |
| 39 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 40 | const permissions: string[] = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 41 | const int = BigInt("0x" + permissionsHex) |
| 42 | .toString(2) |
| 43 | .split("") |
| 44 | .reverse(); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 45 | for (const index in int) { |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 46 | if (int[index] === "1" && array.length > parseInt(index)) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 47 | permissions.push(array[index]!); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 48 | } |
| 49 | } |
| 50 | return permissions; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 51 | }; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 52 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 53 | export { toHexInteger, toHexArray, tickets, logs }; |