blob: fde1340df5ff1a0c7a919f26d709ff4d9019d434 [file] [log] [blame]
const logs = [
"channelUpdate",
"emojiUpdate",
"stickerUpdate",
"guildUpdate",
"guildMemberUpdate",
"guildMemberPunish",
"guildRoleUpdate",
"guildInviteUpdate",
"messageUpdate",
"messageDelete",
"messageDeleteBulk",
"messageReactionUpdate",
"messageMassPing",
"messageAnnounce",
"threadUpdate",
"webhookUpdate",
"guildMemberVerify",
"autoModeratorDeleted",
"ticketUpdate",
// "nucleusSettingsUpdated"
];
const tickets = ["support", "report", "question", "issue", "suggestion", "other"];
const toHexInteger = (permissions: string[], array?: string[]): string => {
if (!array) { array = logs; }
let int = 0n;
for (const perm of permissions) {
int += BigInt(2 ** array.indexOf(perm));
}
return int.toString(16);
};
const toHexArray = (permissionsHex: string, array?: string[]): string[] => {
if (!array) {
array = logs;
}
const permissions: string[] = [];
const int = BigInt("0x" + permissionsHex)
.toString(2)
.split("")
.reverse();
for (const index in int) {
if (int[index] === "1" && array.length > parseInt(index)) {
permissions.push(array[index]!);
}
}
return permissions;
};
export { toHexInteger, toHexArray, tickets, logs };