EDA.API.Reaction (EDA v0.3.0)

Copy Markdown View Source

REST API endpoints for Discord message reactions.

All functions return :ok or {:ok, result} or {:error, reason}. The emoji parameter accepts a string ("👍" or "name:id") or an EDA.Emoji struct.

Summary

Functions

Adds a reaction to a message.

Removes all reactions from a message.

Removes all reactions of a specific emoji from a message.

Removes own reaction from a message.

Removes a user's reaction from a message.

Gets users who reacted with an emoji.

Returns a lazy Stream that paginates through all users who reacted with an emoji.

Functions

create(channel_id, message_id, emoji)

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

Adds a reaction to a message.

delete_all(channel_id, message_id)

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

Removes all reactions from a message.

delete_emoji(channel_id, message_id, emoji)

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

Removes all reactions of a specific emoji from a message.

delete_own(channel_id, message_id, emoji)

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

Removes own reaction from a message.

delete_user(channel_id, message_id, emoji, user_id)

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

Removes a user's reaction from a message.

list(channel_id, message_id, emoji, opts \\ [])

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

Gets users who reacted with an emoji.

stream(channel_id, message_id, emoji, opts \\ [])

@spec stream(
  String.t() | integer(),
  String.t() | integer(),
  String.t() | EDA.Emoji.t(),
  keyword()
) :: Enumerable.t()

Returns a lazy Stream that paginates through all users who reacted with an emoji.

Uses after-only pagination (Discord constraint for the reactions endpoint).

Options

  • :per_page — users per request (1-100, default 100)
  • :after — start after this user ID

Examples

EDA.API.Reaction.stream(channel_id, message_id, "👍") |> Enum.to_list()
EDA.API.Reaction.stream(channel_id, message_id, "👍", per_page: 50)
|> Stream.take(10) |> Enum.to_list()