Lingo.Api.Lobby (Lingo v0.4.2)

Copy Markdown View Source

Lobbies: groups of players for Discord's Social SDK, which a bot can create and manage, and link to a guild text channel.

These are the endpoints a bot token may use; joining, leaving, linking and messaging as a player take the player's own OAuth2 token.

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

Functions

Creates a lobby. Params: :metadata (string keys and values), :members (up to 25, each with an :id and optional :metadata, :flags and :additional_name) and :idle_timeout_seconds (5 to 604800).

Creates a single-use invite, valid for an hour, to the lobby's linked channel, for one of its members. Returns the invite code.

Deletes a lobby; fine if it's already gone.

Removes a member from a lobby; fine if they aren't in it.

Fetches a lobby.

Edits a lobby. :members replaces the whole member list, removing anyone left out.

Adds a member to a lobby, or edits one already in it. Params: :metadata, :flags (1: may link a channel) and :additional_name.

Adds, edits or removes up to 25 members at once. Each is a map with an :id, the fields of update_member/3, and remove_member: true to remove them. Returns the members added or edited.

Sets a lobby message's moderation metadata, sent on to game clients: up to 5 string keys and values.

Functions

create(params \\ %{})

Creates a lobby. Params: :metadata (string keys and values), :members (up to 25, each with an :id and optional :metadata, :flags and :additional_name) and :idle_timeout_seconds (5 to 604800).

create_invite(lobby_id, user_id)

@spec create_invite(Lingo.Api.id(), Lingo.Api.id()) :: Lingo.Api.result(String.t())

Creates a single-use invite, valid for an hour, to the lobby's linked channel, for one of its members. Returns the invite code.

delete(lobby_id)

@spec delete(Lingo.Api.id()) :: Lingo.Api.result()

Deletes a lobby; fine if it's already gone.

delete_member(lobby_id, user_id)

@spec delete_member(Lingo.Api.id(), Lingo.Api.id()) :: Lingo.Api.result()

Removes a member from a lobby; fine if they aren't in it.

get(lobby_id)

Fetches a lobby.

update(lobby_id, params)

Edits a lobby. :members replaces the whole member list, removing anyone left out.

update_member(lobby_id, user_id, params \\ %{})

Adds a member to a lobby, or edits one already in it. Params: :metadata, :flags (1: may link a channel) and :additional_name.

update_members(lobby_id, members)

@spec update_members(Lingo.Api.id(), [map()]) ::
  Lingo.Api.result([Lingo.Type.LobbyMember.t()])

Adds, edits or removes up to 25 members at once. Each is a map with an :id, the fields of update_member/3, and remove_member: true to remove them. Returns the members added or edited.

update_moderation_metadata(lobby_id, message_id, metadata)

@spec update_moderation_metadata(Lingo.Api.id(), Lingo.Api.id(), %{
  required(String.t()) => String.t()
}) ::
  Lingo.Api.result()

Sets a lobby message's moderation metadata, sent on to game clients: up to 5 string keys and values.