Lingo.Collector (Lingo v0.4.2)

Copy Markdown View Source

Waiting for button clicks and reactions inline, instead of in a separate callback.

{:ok, message} = Lingo.Api.Message.create(channel_id, %{content: "Sure?", components: [row]})

case Lingo.Collector.await_component(message.id, timeout: 30_000) do
  {:ok, interaction} -> ...
  :timeout -> ...
end

A component interaction an awaiter takes doesn't reach Lingo.Bot.handle_component/2. Reactions reach the bot as usual.

Summary

Functions

Waits for a component interaction on a message. Options: :filter (a function that gets the interaction) and :timeout (ms, default 60000). Returns {:ok, interaction} or :timeout.

Waits for a reaction on a message. Takes the same options as await_component/2. Returns {:ok, %Lingo.Event.Reaction{}} or :timeout.

Collects every reaction on a message until :timeout (ms, required) runs out. Takes a :filter too. Returns {:ok, [%Lingo.Event.Reaction{}]}.

Functions

await_component(message_id, opts \\ [])

Waits for a component interaction on a message. Options: :filter (a function that gets the interaction) and :timeout (ms, default 60000). Returns {:ok, interaction} or :timeout.

await_reaction(channel_id, message_id, opts \\ [])

Waits for a reaction on a message. Takes the same options as await_component/2. Returns {:ok, %Lingo.Event.Reaction{}} or :timeout.

collect_reactions(channel_id, message_id, opts \\ [])

Collects every reaction on a message until :timeout (ms, required) runs out. Takes a :filter too. Returns {:ok, [%Lingo.Event.Reaction{}]}.