message: add: role bitfield
diff: @@ -19,6 +19,17 @@ const ROLE_SNOWFLAKES = [
  "guildId",
  ];
  +const roleToggles = {
  + /** If this role is showed seperately in the user listing */
  + hoist: 1n,
  + /** Whether this role is managed by an integration */
  + managed: 2n,
  + /** Whether this role is mentionable */
  + mentionable: 4n,
  + /** If this role is the nitro boost role. */
  + isNitroBoostRole: 8n,
  +};
  +
  const baseRole: Partial<DiscordenoRole> = {
  get guild() {
  return cache.guilds.get(this.guildId!);
  @@ -71,6 +82,18 @@ const baseRole: Partial<DiscordenoRole> = {
  memberHighestRole.position,
  );
  },
  + get hoist() {
  + return Boolean(this.bitfield! & roleToggles.hoist);
  + },
  + get managed() {
  + return Boolean(this.bitfield! & roleToggles.managed);
  + },
  + get mentionable() {
  + return Boolean(this.bitfield! & roleToggles.mentionable);
  + },
  + get isNitroBoostRole() {
  + return Boolean(this.bitfield! & roleToggles.isNitroBoostRole);
  + },
  };
  // deno-lint-ignore require-await
  @@ -84,6 +107,8 @@ export async function createDiscordenoRole(
  ...rest
  } = ({ guildId: data.guildId, ...data.role });
  + let bitfield = 0n;
  +
  const props: Record<string, ReturnType<typeof createNewProp>> = {};
  for (const [key, value] of Object.entries(rest)) {
  eventHandlers.debug?.(
  @@ -91,6 +116,12 @@ export async function createDiscordenoRole(
  `Running for of loop in createDiscordenoRole function.`,
  );
  + const toggleBits = roleToggles[key as keyof typeof roleToggles];
  + if (toggleBits) {
  + bitfield |= value ? toggleBits : 0n;
  + continue;
  + }
  +
  props[key] = createNewProp(
  ROLE_SNOWFLAKES.includes(key)
  ? value ? snowflakeToBigint(value) : undefined
  @@ -123,6 +154,8 @@ export interface DiscordenoRole extends Omit<Role, "tags" | "id"> {
  integrationId: bigint;
  /** The roles guildId */
  guildId: bigint;
  + /** Holds all the boolean toggles. */
  + bitfield: bigint;
  // GETTERS
  