REST API endpoints for Discord guilds.
All functions return {:ok, result} or {:error, reason}.
Summary
Functions
Gets the audit log for a guild.
Gets channels in a guild.
Deletes a guild integration, with its webhooks — and kicks its bot, if it has one. Requires
MANAGE_GUILD.
Gets a guild by ID.
Lists a guild's integrations — Twitch, YouTube, and bot or OAuth2 applications. Requires
MANAGE_GUILD. Discord returns at most 50; EDA.Integration.from_raw/1 parses each.
Gets invites for a guild.
Modifies a guild.
Pauses invites or direct messages in a guild during a raid, for up to 24 hours. Requires
MANAGE_GUILD.
Replaces a guild's onboarding. Requires MANAGE_GUILD and MANAGE_ROLES.
Modifies a guild's welcome screen. Requires MANAGE_GUILD. Every field is optional.
Modifies a guild's widget settings. Requires MANAGE_GUILD.
Gets a guild's onboarding: its prompts, default channels, and whether it is enabled.
Gets a guild's preview: name, icon, emojis, stickers, features and approximate counts. For a guild the bot is not in, the guild must be discoverable.
Begins a guild prune. This kicks members.
Gets the number of members that would be pruned.
Gets a guild's vanity invite and how many times it was used, %{"code" => ..., "uses" => ...}.
Requires MANAGE_GUILD and the VANITY_URL feature. The code alone is on the guild object as
vanity_url_code; this route is the only way to the use count.
Lists the voice regions available to a guild, VIP ones included. See EDA.API.Voice.regions/0.
Gets a guild's welcome screen: its description and the channels it recommends. Needs
MANAGE_GUILD while the welcome screen is disabled.
Gets a guild's public widget: its name, online members and instant invite. Needs the widget to be enabled, and nothing else — no permission, no authentication.
The URL of a guild's widget image, a PNG anyone can load while the widget is enabled — for a website or a README. Builds the URL; nothing is fetched.
Gets a guild's widget settings, %{"enabled" => ..., "channel_id" => ...}. Requires MANAGE_GUILD.
Functions
@spec audit_log( String.t() | integer(), keyword() ) :: {:ok, %{entries: [EDA.AuditLog.Entry.t()], users: [map()], webhooks: [map()]}} | {:error, term()}
Gets the audit log for a guild.
Options
:user_id- Filter by user who performed the action:action_type- Filter by action type (integer or atom viaEDA.AuditLog.action_type/1):before- Get entries before this entry ID:after- Get entries after this entry ID:limit- Number of entries (1-100, default 50)
Gets channels in a guild.
@spec delete_integration(String.t() | integer(), String.t() | integer(), keyword()) :: :ok | {:error, term()}
Deletes a guild integration, with its webhooks — and kicks its bot, if it has one. Requires
MANAGE_GUILD.
Options
:reason— audit log reason
Gets a guild by ID.
Lists a guild's integrations — Twitch, YouTube, and bot or OAuth2 applications. Requires
MANAGE_GUILD. Discord returns at most 50; EDA.Integration.from_raw/1 parses each.
Gets invites for a guild.
Modifies a guild.
@spec modify_incident_actions( String.t() | integer(), keyword() ) :: {:ok, map()} | {:error, term()}
Pauses invites or direct messages in a guild during a raid, for up to 24 hours. Requires
MANAGE_GUILD.
Options
:invites_disabled_until— aDateTime(or ISO8601 string) at most 24 hours ahead, ornilto allow invites again:dms_disabled_until— the same, for direct messages between members
Returns the guild's incidents data.
until = DateTime.add(DateTime.utc_now(), 3600)
EDA.API.Guild.modify_incident_actions(guild_id, invites_disabled_until: until)
@spec modify_onboarding(String.t() | integer(), keyword() | map()) :: {:ok, map()} | {:error, term()}
Replaces a guild's onboarding. Requires MANAGE_GUILD and MANAGE_ROLES.
PUT /guilds/{guild_id}/onboarding. Every field is optional, but :prompts, when given, is
the complete list: a prompt left out is deleted. EDA.Onboarding.save/2 is the safe way to
change one prompt among several.
Options
:prompts—EDA.Onboarding.Promptstructs or raw prompt maps. An option's emoji is sent asemoji_id/emoji_name/emoji_animatedwhichever form it came in: Discord ignores theemojiobject it returns, so sending that back would clear the emoji:default_channel_ids— channels every member joins:enabled— enabling needs at least 7 default channels, 5 of them open to@everyone:mode—:defaultor:advanced:reason— audit log reason
@spec modify_welcome_screen(String.t() | integer(), keyword() | map()) :: {:ok, map()} | {:error, term()}
Modifies a guild's welcome screen. Requires MANAGE_GUILD. Every field is optional.
Options
:enabled— whether the welcome screen is shown:description— the server description it shows:welcome_channels— the channels it recommends, each%{channel_id: ..., description: ..., emoji_id: ..., emoji_name: ...}:reason— audit log reason
Modifies a guild's widget settings. Requires MANAGE_GUILD.
Options
:enabled— whether the widget is on:channel_id— the channel its invite leads to, ornil:reason— audit log reason
Gets a guild's onboarding: its prompts, default channels, and whether it is enabled.
GET /guilds/{guild_id}/onboarding. EDA.Onboarding.fetch/1 returns it as a struct.
Gets a guild's preview: name, icon, emojis, stickers, features and approximate counts. For a guild the bot is not in, the guild must be discoverable.
Begins a guild prune. This kicks members.
Requires MANAGE_GUILD and KICK_MEMBERS — or ADMINISTRATOR when the guild has the
PRUNE_REQUIRES_ADMIN feature, which its owner can turn on.
Options
:days- inactivity threshold, 1–30, default 7:compute_prune_count- whether the response reports how many were removed. Discord advisesfalseon large guilds:include_roles- role ids whose members are eligible; without it, members with any role are spared:reason- audit log reason
Accepts a keyword list or a map. An option this endpoint does not define raises
ArgumentError and nothing is sent: Discord ignores an unrecognised body field, so day: 30
would prune on the default 7 days — a destructive call doing more than it was asked.
Gets the number of members that would be pruned.
Requires MANAGE_GUILD and KICK_MEMBERS — or ADMINISTRATOR when the guild has the
PRUNE_REQUIRES_ADMIN feature, which its owner can turn on.
Gets a guild's vanity invite and how many times it was used, %{"code" => ..., "uses" => ...}.
Requires MANAGE_GUILD and the VANITY_URL feature. The code alone is on the guild object as
vanity_url_code; this route is the only way to the use count.
Lists the voice regions available to a guild, VIP ones included. See EDA.API.Voice.regions/0.
Gets a guild's welcome screen: its description and the channels it recommends. Needs
MANAGE_GUILD while the welcome screen is disabled.
Gets a guild's public widget: its name, online members and instant invite. Needs the widget to be enabled, and nothing else — no permission, no authentication.
The URL of a guild's widget image, a PNG anyone can load while the widget is enabled — for a website or a README. Builds the URL; nothing is fetched.
style is one of :shield (the default), :banner1 to :banner4.
iex> EDA.API.Guild.widget_image_url("1", :banner2)
"https://discord.com/api/v10/guilds/1/widget.png?style=banner2"
Gets a guild's widget settings, %{"enabled" => ..., "channel_id" => ...}. Requires MANAGE_GUILD.