EDA.API.GuildTemplate (EDA v0.3.0)

Copy Markdown View Source

REST API endpoints for Discord guild templates.

All functions return {:ok, result} or {:error, reason}.

Summary

Functions

Creates a guild template.

Creates a new guild from a template.

Deletes a guild template. Returns the deleted template.

Gets a guild template by its code.

Lists all templates for a guild.

Modifies a guild template's metadata.

Syncs a guild template with the current guild state.

Functions

create(guild_id, params)

@spec create(String.t() | integer(), map()) ::
  {:ok, EDA.GuildTemplate.t()} | {:error, term()}

Creates a guild template.

Requires the MANAGE_GUILD permission.

Parameters

  • guild_id - The guild ID
  • params - Map with:
    • :name - Template name (required, 1-100 chars)
    • :description - Template description (optional, 0-120 chars)

create_guild(code, params)

@spec create_guild(String.t(), map()) :: {:ok, map()} | {:error, term()}

Creates a new guild from a template.

The bot must be in fewer than 10 guilds. Returns the raw guild object as a map.

Parameters

  • code - The template code
  • params - Map with:
    • :name - Guild name (required, 2-100 chars)
    • :icon - Base64 128x128 image for the guild icon (optional)

delete(guild_id, code)

@spec delete(String.t() | integer(), String.t()) ::
  {:ok, EDA.GuildTemplate.t()} | {:error, term()}

Deletes a guild template. Returns the deleted template.

Requires the MANAGE_GUILD permission.

Parameters

  • guild_id - The guild ID
  • code - The template code

get(code)

@spec get(String.t()) :: {:ok, EDA.GuildTemplate.t()} | {:error, term()}

Gets a guild template by its code.

This endpoint does not require authentication.

Parameters

  • code - The template code (e.g. "hgM48av5Q69A")

list(guild_id)

@spec list(String.t() | integer()) ::
  {:ok, [EDA.GuildTemplate.t()]} | {:error, term()}

Lists all templates for a guild.

Requires the MANAGE_GUILD permission.

Parameters

  • guild_id - The guild ID

modify(guild_id, code, params)

@spec modify(String.t() | integer(), String.t(), map()) ::
  {:ok, EDA.GuildTemplate.t()} | {:error, term()}

Modifies a guild template's metadata.

Requires the MANAGE_GUILD permission.

Parameters

  • guild_id - The guild ID
  • code - The template code
  • params - Map with:
    • :name - Template name (optional, 1-100 chars)
    • :description - Template description (optional, 0-120 chars)

sync(guild_id, code)

@spec sync(String.t() | integer(), String.t()) ::
  {:ok, EDA.GuildTemplate.t()} | {:error, term()}

Syncs a guild template with the current guild state.

Requires the MANAGE_GUILD permission. This is a PUT with no body.

Parameters

  • guild_id - The guild ID
  • code - The template code