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", |
| 20 | "nucleusSettingsUpdated", |
| 21 | "ticketUpdate" |
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 => { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 27 | if (!array) { |
| 28 | array = logs; |
| 29 | } |
| 30 | let int = 0n; |
| 31 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 32 | for (const perm of permissions) { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 33 | int += BigInt(2 ** array.indexOf(perm)); |
| 34 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 35 | return int.toString(16); |
| 36 | }; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 37 | |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 38 | const toHexArray = (permissionsHex: string, array?: string[]): string[] => { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 39 | if (!array) { |
| 40 | array = logs; |
| 41 | } |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 42 | const permissions: string[] = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 43 | const int = BigInt("0x" + permissionsHex) |
| 44 | .toString(2) |
| 45 | .split("") |
| 46 | .reverse(); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 47 | for (const index in int) { |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 48 | if (int[index] === "1" && array.length > parseInt(index)) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 49 | permissions.push(array[index]!); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | return permissions; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 53 | }; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 54 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 55 | export { toHexInteger, toHexArray, tickets, logs }; |