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 | |
| 24 | const tickets = [ |
| 25 | "support", |
| 26 | "report", |
| 27 | "question", |
| 28 | "issue", |
| 29 | "suggestion", |
| 30 | "other" |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 31 | ]; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 32 | |
| 33 | const toHexInteger = (permissions, array?) => { |
| 34 | if (!array) { |
| 35 | array = logs; |
| 36 | } |
| 37 | let int = 0n; |
| 38 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 39 | for (const perm of permissions) { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 40 | int += BigInt(2 ** array.indexOf(perm)); |
| 41 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 42 | return int.toString(16); |
| 43 | }; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 44 | |
| 45 | const toHexArray = (permissionsHex, array?) => { |
| 46 | if (!array) { |
| 47 | array = logs; |
| 48 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 49 | const permissions = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 50 | const int = BigInt("0x" + permissionsHex) |
| 51 | .toString(2) |
| 52 | .split("") |
| 53 | .reverse(); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 54 | for (const index in int) { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 55 | if (int[index] === "1" && array.length > index) { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 56 | permissions.push(array[index]); |
| 57 | } |
| 58 | } |
| 59 | return permissions; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 60 | }; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 61 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 62 | export { toHexInteger, toHexArray, tickets, logs }; |