EDA.API.Application (EDA v0.5.0-beta.2)

Copy Markdown View Source

REST API endpoints for the bot's own application.

All functions return raw maps: {:ok, map} or {:error, reason}. EDA.App wraps them in a struct. (The struct is not called EDA.Application: that is EDA's OTP application.)

Summary

Functions

Gets an Activity instance of this application, if it exists.

Gets the application the bot belongs to.

Edits the application the bot belongs to. Only the fields passed change.

Gets the app's role connection metadata: the fields a guild can require of a linked account to grant a role.

Replaces the app's role connection metadata — the list sent is the whole list, at most 5.

Functions

activity_instance(instance_id)

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

Gets an Activity instance of this application, if it exists.

GET /applications/{application_id}/activity-instances/{instance_id}. Useful to check that a user joining an Activity session is really in it.

me()

@spec me() :: {:ok, map()} | {:error, term()}

Gets the application the bot belongs to.

GET /applications/@me

modify_me(opts)

@spec modify_me(keyword() | map()) :: {:ok, map()} | {:error, term()}

Edits the application the bot belongs to. Only the fields passed change.

PATCH /applications/@me

Options

  • :description — the app's description
  • :icon, :cover_image — image data: a path, raw PNG/JPEG/GIF bytes or a data URI, see EDA.ImageData; nil removes it
  • :tags — up to 5 tags of up to 20 characters each. Discord stores them in an order of its own, so compare them as sets; [] clears them
  • :flags — only the limited intents can be set here: :gateway_presence_limited, :gateway_guild_members_limited, :gateway_message_content_limited, as a list of those atoms or as an integer. Discord refuses any other flag
  • :install_params — the default in-app authorization link, as %{scopes: [...], permissions: ...}; permissions may be an integer, a string or a list of EDA.Permission atoms
  • :integration_types_config — the default scopes and permissions per installation context, keyed by :guild_install and :user_install, each with an install_params value: %{guild_install: %{scopes: ["bot", "applications.commands"], permissions: [:send_messages]}}
  • :custom_install_url, :role_connections_verification_url, :interactions_endpoint_url — URLs. Discord checks an interactions endpoint before accepting it
  • :event_webhooks_url, :event_webhooks_types — webhook events, and :event_webhooks_status as :enabled or :disabled

Example

EDA.API.Application.modify_me(description: "Moderation for busy servers", tags: ["moderation"])

role_connection_metadata()

@spec role_connection_metadata() :: {:ok, [map()]} | {:error, term()}

Gets the app's role connection metadata: the fields a guild can require of a linked account to grant a role.

update_role_connection_metadata(records)

@spec update_role_connection_metadata([map()]) :: {:ok, [map()]} | {:error, term()}

Replaces the app's role connection metadata — the list sent is the whole list, at most 5.

Each record is a map with :type, :key, :name, :description, and optionally :name_localizations and :description_localizations. :type may be an atom: :integer_less_than_or_equal, :integer_greater_than_or_equal, :integer_equal, :integer_not_equal, :datetime_less_than_or_equal, :datetime_greater_than_or_equal, :boolean_equal, :boolean_not_equal. A :key is 1–50 characters of a-z, 0-9 and _.

EDA.API.Application.update_role_connection_metadata([
  %{type: :integer_greater_than_or_equal, key: "level", name: "Level", description: "Minimum level"}
])