REST API endpoints for Discord guild members.
All functions return {:ok, result} or {:error, reason}.
Summary
Functions
Adds a role to a guild member.
Gets a member of a guild.
Lists members of a guild.
Modifies a guild member.
Modifies the bot's own member in a guild — its per-guild profile.
Moves a member to a different voice channel.
Removes a member from a guild (kick).
Removes a role from a guild member.
Searches guild members by username/nickname.
Returns a lazy Stream that paginates through all members of a guild.
Functions
@spec add_role( String.t() | integer(), String.t() | integer(), String.t() | integer(), keyword() ) :: :ok | {:error, term()}
Adds a role to a guild member.
Gets a member of a guild.
Lists members of a guild.
@spec modify(String.t() | integer(), String.t() | integer(), map(), keyword()) :: {:ok, map()} | {:error, term()}
Modifies a guild member.
Modifies the bot's own member in a guild — its per-guild profile.
PATCH /guilds/{guild_id}/members/@me. This is a different endpoint from modify/4, and
the only one that can set the bot's avatar, banner and bio for one guild. The bot keeps
its account-wide identity from EDA.API.User.modify_me/1; what is set here overrides it
in this guild alone.
Options
:nick- guild nickname. The only field that needs a permission:CHANGE_NICKNAME:avatar- guild avatar, as image data:banner- guild banner, as image data:bio- guild bio:reason- audit log reason
Pass nil for any of them to clear it and fall back to the account-wide value. Fields
you leave out are untouched, so setting a bio alone keeps the avatar and banner.
bio is echoed by this endpoint's own response but is not part of the guild member
object Discord returns from get/2 — reading the member back will not give it to you.
Images
:avatar and :banner are image data, a base64 data URI rather than a file upload.
A path or raw bytes is converted for you, and the media type comes from the bytes rather
than the extension — see EDA.ImageData:
EDA.API.Member.modify_me(guild_id,
nick: "EDA",
avatar: "priv/avatar.png",
bio: "Built on OTP",
reason: "profile refresh"
)
# clears the guild avatar, restoring the account-wide one
EDA.API.Member.modify_me(guild_id, avatar: nil)
@spec move_voice( String.t() | integer(), String.t() | integer(), String.t() | integer() | nil ) :: {:ok, map()} | {:error, term()}
Moves a member to a different voice channel.
Pass nil as channel_id to disconnect the user from voice.
Examples
EDA.API.Member.move_voice(guild_id, user_id, new_channel_id)
EDA.API.Member.move_voice(guild_id, user_id, nil) # disconnect
Removes a member from a guild (kick).
@spec remove_role( String.t() | integer(), String.t() | integer(), String.t() | integer(), keyword() ) :: :ok | {:error, term()}
Removes a role from a guild member.
Searches guild members by username/nickname.
@spec stream( String.t() | integer(), keyword() ) :: Enumerable.t()
Returns a lazy Stream that paginates through all members of a guild.
Uses after-only pagination (Discord constraint for the members endpoint).
Options
:per_page— members per request (1-1000, default 1000):after— start after this user ID
Examples
EDA.API.Member.stream(guild_id) |> Enum.to_list()
EDA.API.Member.stream(guild_id) |> Stream.filter(&(&1["user"]["bot"])) |> Enum.to_list()