Messages: sending, forwarding, editing, deleting, bulk deletion and search.
Every function returns {:ok, result}, :ok when Discord sends no body, or
{:error, %Lingo.Error{}}. Calls go to the current bot (see Lingo.with_bot/2).
Summary
Types
A page of search results. messages nests each match in a list of its
own, as Discord sends them; threads are the threads they're in, and
members the bot's membership in those it has joined.
Functions
Deletes many messages at once, in chunks of 100. Messages older than two weeks can't be bulk deleted.
Sends a message. Pass a string, or a map or keyword list of message fields, including :files as {name, binary} tuples.
Publishes a message in an announcement channel to its followers.
Deletes a message.
Forwards a message into channel_id. The bot must be able to read the
message's content (Discord answers code 160014 otherwise).
Fetches a message.
Lists a channel's messages, newest first. Takes limit:, before:, after: and around:.
Searches a guild's messages with Discord's search options (content:,
author_id:, channel_id:, has:, limit:, offset:...); options that
take several values take lists. Retries while Discord is still indexing
the guild: :search_index_retries times (3), waiting what Discord asks or
:search_index_short_delay ms (1000).
Edits a message the bot sent.
Types
@type search_result() :: %{ doing_deep_historical_index: boolean(), documents_indexed: non_neg_integer() | nil, total_results: non_neg_integer(), messages: [[Lingo.Type.Message.t()]], threads: [Lingo.Type.Channel.t()], members: [Lingo.Type.ThreadMember.t()] }
A page of search results. messages nests each match in a list of its
own, as Discord sends them; threads are the threads they're in, and
members the bot's membership in those it has joined.
Functions
@spec bulk_delete(Lingo.Api.id(), [Lingo.Api.id()], keyword()) :: Lingo.Api.result()
Deletes many messages at once, in chunks of 100. Messages older than two weeks can't be bulk deleted.
@spec create(Lingo.Api.id(), Lingo.Api.content()) :: Lingo.Api.result(Lingo.Type.Message.t())
Sends a message. Pass a string, or a map or keyword list of message fields, including :files as {name, binary} tuples.
@spec crosspost(Lingo.Api.id(), Lingo.Api.id()) :: Lingo.Api.result(Lingo.Type.Message.t())
Publishes a message in an announcement channel to its followers.
@spec delete(Lingo.Api.id(), Lingo.Api.id(), keyword()) :: Lingo.Api.result()
Deletes a message.
@spec forward(Lingo.Api.id(), Lingo.Api.id(), Lingo.Api.id()) :: Lingo.Api.result(Lingo.Type.Message.t())
Forwards a message into channel_id. The bot must be able to read the
message's content (Discord answers code 160014 otherwise).
@spec get(Lingo.Api.id(), Lingo.Api.id()) :: Lingo.Api.result(Lingo.Type.Message.t())
Fetches a message.
@spec list( Lingo.Api.id(), keyword() ) :: Lingo.Api.result([Lingo.Type.Message.t()])
Lists a channel's messages, newest first. Takes limit:, before:, after: and around:.
@spec search( Lingo.Api.id(), keyword() ) :: Lingo.Api.result(search_result())
Searches a guild's messages with Discord's search options (content:,
author_id:, channel_id:, has:, limit:, offset:...); options that
take several values take lists. Retries while Discord is still indexing
the guild: :search_index_retries times (3), waiting what Discord asks or
:search_index_short_delay ms (1000).
@spec update(Lingo.Api.id(), Lingo.Api.id(), Lingo.Api.content()) :: Lingo.Api.result(Lingo.Type.Message.t())
Edits a message the bot sent.
:attachments lists every attachment to keep, by :id, and may change
their :description or mark them is_spoiler: true; new :files are
added to them.