Lingo.Flags (Lingo v0.4.2)

Copy Markdown View Source

Flag bitfields other than permissions (see Lingo.Permissions).

Structs keep Discord's integer in their flags field (public_flags for users); these functions read and build it with atoms, Discord's names lowercased. kind is one of :message, :user, :member, :channel, :attachment, :system_channel, :role, :application, :embed or :sku.

Lingo.Flags.has?(:message, message.flags, :is_voice_message)
Lingo.Flags.to_list(:user, user.public_flags)
#=> [:hypesquad_online_house_1, :verified_developer]
Lingo.Flags.from_list(:message, [:suppress_embeds, :suppress_notifications])
#=> 4100

Summary

Functions

Combines flags into a bitfield.

Whether flag is set. Bitfields may be integers or strings (as in flags_new).

The flags set in a bitfield. Bits Lingo doesn't know are left out.

Types

kind()

@type kind() ::
  :message
  | :user
  | :member
  | :channel
  | :attachment
  | :system_channel
  | :role
  | :application
  | :embed
  | :sku

Functions

from_list(kind, flags)

@spec from_list(kind(), [atom()]) :: integer()

Combines flags into a bitfield.

has?(kind, bitfield, flag)

@spec has?(kind(), integer() | String.t() | nil, atom()) :: boolean()

Whether flag is set. Bitfields may be integers or strings (as in flags_new).

to_list(kind, bitfield)

@spec to_list(kind(), integer() | String.t() | nil) :: [atom()]

The flags set in a bitfield. Bits Lingo doesn't know are left out.