crux_structs v0.2.3 Crux.Structs.User.Flags View Source

Custom non discord API struct helping with the usage of user flags.

Discord is only providing a not documented subset of the available flags to bots.

Link to this section Summary

Types

Union type of all valid user flags.

Raw bitfield that can be used as a t:resolvable/0.

All valid types that can be directly resolved into a bitfield.

t()

Functions

Add all set bits of to_add to base.

Get an integer representing all available bits set.

Get a map of t:name/0s and their corresponding bit values.

Check whether the t:resolvable/0 you have has everything set you want.

Return a t:t/0 of all bits you want but not have.

Get a list of all available t:name/0s.

Remove all set bits of to_remove from base.

Resolve a t:resolvable/0 into a bitfield.

Serialize a t:resolvable/0 into a list of set bit flag names.

Serialize a t:resolvable/0 into a map representing bit flag names to whether they are set.

Link to this section Types

Specs

name() ::
  :discord_employee
  | :discord_partner
  | :hypesquad_events
  | :bughunter_level_1
  | :house_bravery
  | :house_brilliance
  | :house_balance
  | :early_supporter
  | :team_user
  | :system
  | :bughunter_level_2
  | :verified_bot
  | :verified_developer

Union type of all valid user flags.

Specs

raw() :: non_neg_integer()

Raw bitfield that can be used as a t:resolvable/0.

Specs

resolvable() :: t() | raw() | name() | [resolvable()]

All valid types that can be directly resolved into a bitfield.

Specs

t() :: %Crux.Structs.User.Flags{bitfield: non_neg_integer()}

Link to this section Functions

Specs

add(base :: resolvable(), to_add :: resolvable()) :: t()

Add all set bits of to_add to base.

Specs

all() :: non_neg_integer()

Get an integer representing all available bits set.

Specs

flags() :: %{required(name()) => non_neg_integer()}

Get a map of t:name/0s and their corresponding bit values.

Specs

has(have :: resolvable(), want :: resolvable()) :: boolean()

Check whether the t:resolvable/0 you have has everything set you want.

Specs

missing(resolvable(), resolvable()) :: t()

Return a t:t/0 of all bits you want but not have.

Specs

names() :: [name()]

Get a list of all available t:name/0s.

Specs

new(resolvable()) :: t()

Create a new t:t/0 from a t:resolvable/0.

Specs

remove(base :: resolvable(), to_remove :: resolvable()) :: t()

Remove all set bits of to_remove from base.

Specs

resolve(resolvable()) :: non_neg_integer()

Resolve a t:resolvable/0 into a bitfield.

Specs

to_list(resolvable()) :: [name()]

Serialize a t:resolvable/0 into a list of set bit flag names.

Specs

to_map(resolvable()) :: %{required(name()) => boolean()}

Serialize a t:resolvable/0 into a map representing bit flag names to whether they are set.