crux_structs v0.2.3 Crux.Structs.Permissions View Source

Custom non discord api struct to help with working with permissions.

For more informations see Discord Docs.

Link to this section Summary

Types

Union type of all valid permission name atoms.

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.

Resolves permissions for a user in a guild, optionally including channel permission overwrites.

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.

Resolves permissions for a user in a guild, optionally including channel permission overwrites.

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() ::
  :create_instant_invite
  | :kick_members
  | :ban_members
  | :administrator
  | :manage_channels
  | :manage_guild
  | :add_reactions
  | :view_audit_log
  | :priority_speaker
  | :stream
  | :view_channel
  | :send_messages
  | :send_tts_message
  | :manage_messages
  | :embed_links
  | :attach_files
  | :read_message_histroy
  | :mention_everyone
  | :use_external_emojis
  | :view_guild_insights
  | :connect
  | :speak
  | :mute_members
  | :deafen_members
  | :move_members
  | :use_vad
  | :change_nickname
  | :manage_nicknames
  | :manage_roles
  | :manage_webhooks
  | :manage_emojis

Union type of all valid permission name atoms.

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.Permissions{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.

Link to this function

explicit(member, guild, channel \\ nil)

View Source (since 0.2.0)

Specs

explicit(
  member ::
    Crux.Structs.Member.t() | Crux.Structs.User.t() | Crux.Structs.Snowflake.t(),
  guild :: Crux.Structs.Guild.t(),
  channel :: Crux.Structs.Channel.t() | nil
) :: t()

Resolves permissions for a user in a guild, optionally including channel permission overwrites.

Raises when the member is not cached.

The administrator flag or being owner implicitly does not grant permissions, see implicit/3.

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.

Link to this function

implicit(member, guild, channel \\ nil)

View Source (since 0.2.0)

Specs

implicit(
  member ::
    Crux.Structs.Member.t() | Crux.Structs.User.t() | Crux.Structs.Snowflake.t(),
  guild :: Crux.Structs.Guild.t(),
  channel :: Crux.Structs.Channel.t() | nil
) :: t()

Resolves permissions for a user in a guild, optionally including channel permission overwrites.

Raises when the member is not cached.

The guild-wide administrator flag or being owner implicitly grants all permissions, see explicit/3.

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.