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", |
| 14 | "messagePing", |
| 15 | "messageMassPing", |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 16 | "messageAnnounce", |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 17 | "threadUpdate", |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 18 | "webhookUpdate", |
pineafan | 412beec | 2022-06-29 21:46:26 +0100 | [diff] [blame] | 19 | "guildMemberVerify", |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 20 | "autoModeratorDeleted", // TODO: Not implemented |
| 21 | "nucleusSettingsUpdated" |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 22 | ] |
| 23 | |
| 24 | const tickets = [ |
| 25 | "support", |
| 26 | "report", |
| 27 | "question", |
| 28 | "issue", |
| 29 | "suggestion", |
| 30 | "other" |
| 31 | ] |
| 32 | |
| 33 | const toHexInteger = (permissions, array?) => { |
| 34 | if (!array) { |
| 35 | array = logs; |
| 36 | } |
| 37 | let int = 0n; |
| 38 | |
| 39 | for(let perm of permissions) { |
| 40 | int += BigInt(2 ** array.indexOf(perm)); |
| 41 | } |
| 42 | return int.toString(16) |
| 43 | } |
| 44 | |
| 45 | const toHexArray = (permissionsHex, array?) => { |
| 46 | if (!array) { |
| 47 | array = logs; |
| 48 | } |
| 49 | let permissions = []; |
| 50 | let int = (BigInt("0x" + permissionsHex)).toString(2).split('').reverse(); |
| 51 | for (let index in int) { |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 52 | if (int[index] == "1" && array.length > index) { |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 53 | permissions.push(array[index]); |
| 54 | } |
| 55 | } |
| 56 | return permissions; |
| 57 | } |
| 58 | |
| 59 | export { |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 60 | toHexInteger, |
| 61 | toHexArray, |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 62 | tickets, |
| 63 | logs |
| 64 | } |