EDA.Message (EDA v0.3.0)

Copy Markdown View Source

Represents a Discord message.

Summary

Functions

Applies a changeset to a message. No-op if the changeset has no changes.

Adds a change to an existing changeset for this entity.

Creates a changeset for batching mutations to this entity.

Deletes a message.

Edits a message. Accepts a struct or channel_id + message_id.

Fetches a message by channel ID and message ID. No cache (messages are not cached).

Pins a message in its channel.

Adds a reaction to a message.

Replies to a message. Returns a %EDA.Message{} struct.

Unpins a message from its channel.

Types

t()

@type t() :: %EDA.Message{
  attachments: [EDA.Attachment.t()] | nil,
  author: EDA.User.t() | nil,
  channel_id: String.t() | nil,
  components: [map()] | nil,
  content: String.t() | nil,
  edited_timestamp: String.t() | nil,
  embeds: [map()] | nil,
  guild_id: String.t() | nil,
  id: String.t() | nil,
  member: EDA.Member.t() | nil,
  mention_everyone: boolean() | nil,
  mention_roles: [String.t()] | nil,
  mentions: [EDA.User.t()] | nil,
  message_reference: map() | nil,
  pinned: boolean() | nil,
  poll: EDA.Poll.t() | nil,
  reactions: [EDA.Reaction.t()] | nil,
  referenced_message: t() | nil,
  sticker_items: [map()] | nil,
  timestamp: String.t() | nil,
  tts: boolean() | nil,
  type: integer() | nil
}

Functions

apply_changeset(changeset, opts \\ [])

@spec apply_changeset(
  EDA.Entity.Changeset.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Applies a changeset to a message. No-op if the changeset has no changes.

change(cs, key, value)

Adds a change to an existing changeset for this entity.

changeset(entity)

@spec changeset(t()) :: EDA.Entity.Changeset.t()

Creates a changeset for batching mutations to this entity.

delete(message, opts \\ [])

@spec delete(
  t(),
  keyword()
) :: :ok | {:error, term()}

Deletes a message.

Options

  • :reason - Audit log reason

edit(message, payload)

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

Edits a message. Accepts a struct or channel_id + message_id.

fetch_message(channel_id, message_id)

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

Fetches a message by channel ID and message ID. No cache (messages are not cached).

from_raw(raw)

@spec from_raw(map()) :: t()

pin(message, opts \\ [])

@spec pin(
  t(),
  keyword()
) :: :ok | {:error, term()}

Pins a message in its channel.

Options

  • :reason - Audit log reason

react(message, emoji)

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

Adds a reaction to a message.

The emoji parameter accepts a string ("👍" or "name:id") or an EDA.Emoji struct.

reply(message, content)

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

Replies to a message. Returns a %EDA.Message{} struct.

unpin(message, opts \\ [])

@spec unpin(
  t(),
  keyword()
) :: :ok | {:error, term()}

Unpins a message from its channel.

Options

  • :reason - Audit log reason