EDA.Command.Permissions (EDA v0.5.0-beta.2)

Copy Markdown View Source

Who may use one of the app's commands in a guild — or every command, when id is the application id.

Arrives with APPLICATION_COMMAND_PERMISSIONS_UPDATE. Each entry allows or denies a role, a user or a channel. Two ids are constants rather than real ids: the guild id stands for @everyone, and the guild id minus one for every channel — everyone?/2 and all_channels?/2 recognise them.

Summary

Functions

Whether an entry targets every channel — a channel entry whose id is the guild id minus one.

Whether these permissions apply to every command of the app rather than one.

Whether an entry targets @everyone — a role entry whose id is the guild id.

Converts a raw guild application command permissions object into this struct.

Types

entry()

@type entry() :: %{
  id: String.t(),
  type: :role | :user | :channel | integer(),
  permission: boolean()
}

t()

@type t() :: %EDA.Command.Permissions{
  application_id: String.t() | nil,
  guild_id: String.t() | nil,
  id: String.t() | nil,
  permissions: [entry()]
}

Functions

all_channels?(arg1, guild_id)

@spec all_channels?(entry(), String.t()) :: boolean()

Whether an entry targets every channel — a channel entry whose id is the guild id minus one.

iex> EDA.Command.Permissions.all_channels?(%{id: "9", type: :channel}, "10")
true

app_wide?(permissions)

@spec app_wide?(t()) :: boolean()

Whether these permissions apply to every command of the app rather than one.

everyone?(arg1, guild_id)

@spec everyone?(entry(), String.t()) :: boolean()

Whether an entry targets @everyone — a role entry whose id is the guild id.

iex> EDA.Command.Permissions.everyone?(%{id: "10", type: :role}, "10")
true

from_raw(raw)

@spec from_raw(map()) :: t()

Converts a raw guild application command permissions object into this struct.