Represents a Discord guild member.
Summary
Functions
Adds a role to a guild member.
Applies a changeset to a member. No-op if the changeset has no changes.
Adds a change to an existing changeset for this entity.
Creates a changeset for batching mutations to this entity.
Fetches a member by guild ID and user ID. Checks cache first, falls back to REST.
Kicks a member from a guild.
Modifies a guild member.
Removes a role from a guild member.
When the member's timeout ends, or nil if they have never been timed out.
Returns true while the member is currently timed out.
Types
@type t() :: %EDA.Member{ avatar: String.t() | nil, communication_disabled_until: String.t() | nil, deaf: boolean() | nil, joined_at: String.t() | nil, mute: boolean() | nil, nick: String.t() | nil, pending: boolean() | nil, premium_since: String.t() | nil, roles: [String.t()] | nil, user: EDA.User.t() | nil }
Functions
@spec add_role( String.t() | integer(), t() | String.t() | integer(), String.t() | integer(), keyword() ) :: :ok | {:error, term()}
Adds a role to a guild member.
Options
:reason- Audit log reason
@spec apply_changeset(String.t() | integer(), EDA.Entity.Changeset.t(), keyword()) :: {:ok, t()} | {:error, term()}
Applies a changeset to a member. No-op if the changeset has no changes.
Requires guild_id since members are guild-scoped.
Options
:reason- Audit log reason
@spec change(EDA.Entity.Changeset.t(), atom(), term()) :: EDA.Entity.Changeset.t()
Adds a change to an existing changeset for this entity.
@spec changeset(t()) :: EDA.Entity.Changeset.t()
Creates a changeset for batching mutations to this entity.
Fetches a member by guild ID and user ID. Checks cache first, falls back to REST.
@spec kick(String.t() | integer(), t() | String.t() | integer(), keyword()) :: :ok | {:error, term()}
Kicks a member from a guild.
Options
:reason- Audit log reason
@spec modify(String.t() | integer(), t() | String.t() | integer(), map(), keyword()) :: {:ok, t()} | {:error, term()}
Modifies a guild member.
Options
:reason- Audit log reason
@spec remove_role( String.t() | integer(), t() | String.t() | integer(), String.t() | integer(), keyword() ) :: :ok | {:error, term()}
Removes a role from a guild member.
Options
:reason- Audit log reason
@spec time_out_end(t() | map()) :: DateTime.t() | nil
When the member's timeout ends, or nil if they have never been timed out.
May return a date in the past, in which case the timeout has expired — Discord
leaves the field populated. Use timed_out?/1 to ask whether it is currently active.
JDA draws the same distinction with getTimeOutEnd() / isTimedOut().
Accepts a struct or a raw member map.
Examples
iex> EDA.Member.time_out_end(%EDA.Member{communication_disabled_until: "2099-01-01T00:00:00Z"})
~U[2099-01-01 00:00:00Z]
iex> EDA.Member.time_out_end(%EDA.Member{})
nil
Returns true while the member is currently timed out.
Accepts a struct or a raw member map.
Not reflected in permissions
Discord removes every permission except VIEW_CHANNEL and READ_MESSAGE_HISTORY
from a timed-out member, but EDA.Permission.in_channel/3 does not account for
it — neither does JDA's hasPermission. Check this yourself before gating an action
on a permission.
Examples
iex> EDA.Member.timed_out?(%EDA.Member{communication_disabled_until: "2099-01-01T00:00:00Z"})
true
iex> EDA.Member.timed_out?(%EDA.Member{communication_disabled_until: "2020-01-01T00:00:00Z"})
false
iex> EDA.Member.timed_out?(%EDA.Member{})
false