Permission bitfields.
Discord sends permissions as bitfields (often as strings). These functions
check and build them using atoms like :send_messages and :ban_members.
Lingo.Permissions.has?(member_permissions, :manage_messages)
Lingo.Permissions.from_list([:view_channel, :send_messages])
#=> 3072
Summary
Functions
Every permission atom Lingo knows.
Effective permissions of a member in a channel: the @everyone role's
permissions, plus their roles', then the channel's overwrites for
@everyone, their roles and them. Administrators get everything.
Combines permission atoms (and raw bits) into a bitfield.
Whether the bitfield includes permission. Administrator doesn't imply anything here; use compute/5 for effective permissions.
Whether the bitfield includes every one of permissions.
Whether the bitfield includes at least one of permissions.
The permission atoms set in a bitfield.
Types
@type permission() :: atom()
Functions
@spec all() :: [permission()]
Every permission atom Lingo knows.
@spec compute( base_permissions :: String.t() | integer(), member_role_ids :: [String.t()], roles :: [%{id: String.t(), permissions: String.t()}], channel_overwrites :: [ %{ id: String.t(), type: :role | :member, allow: String.t(), deny: String.t() } ], member_id :: String.t() | nil ) :: integer()
Effective permissions of a member in a channel: the @everyone role's
permissions, plus their roles', then the channel's overwrites for
@everyone, their roles and them. Administrators get everything.
roles are the guild's Lingo.Type.Role structs and overwrites the
channel's Lingo.Type.Overwrite structs. Lingo.Helper.Channel.permissions/2
does this from the cache.
@spec from_list([permission()]) :: integer()
Combines permission atoms (and raw bits) into a bitfield.
@spec has?(String.t() | integer(), permission()) :: boolean()
Whether the bitfield includes permission. Administrator doesn't imply anything here; use compute/5 for effective permissions.
@spec has_all?(String.t() | integer(), [permission()]) :: boolean()
Whether the bitfield includes every one of permissions.
@spec has_any?(String.t() | integer(), [permission()]) :: boolean()
Whether the bitfield includes at least one of permissions.
@spec to_list(String.t() | integer()) :: [permission()]
The permission atoms set in a bitfield.