libduvet/http/bot

Values

pub fn create_command(
  client: client.RestClient,
  team_id: String,
  application_id: String,
  command: json.Json,
) -> Result(json.Json, error.DuvetError)

Registers one command.

pub fn delete_command(
  client: client.RestClient,
  team_id: String,
  application_id: String,
  command_id: String,
) -> Result(Nil, error.DuvetError)
pub fn delete_message(
  client: client.RestClient,
  application_id: String,
  token: String,
  message_ref: String,
) -> Result(Nil, error.DuvetError)

Deletes @original, or a follow-up.

pub fn delete_message_in_room(
  client: client.RestClient,
  room_id: String,
  message_id: String,
) -> Result(Nil, error.DuvetError)
pub fn edit_message(
  client: client.RestClient,
  application_id: String,
  token: String,
  message_ref: String,
  message: json.Json,
) -> Result(Nil, error.DuvetError)

Edits @original (which completes a deferred response), or a follow-up.

pub fn edit_message_in_room(
  client: client.RestClient,
  room_id: String,
  message_id: String,
  message: json.Json,
) -> Result(json.Json, error.DuvetError)

Edits one of the bot’s messages. What it leaves out stays as it was.

pub fn follow_up(
  client: client.RestClient,
  application_id: String,
  token: String,
  message: json.Json,
) -> Result(json.Json, error.DuvetError)

A follow-up of an interaction: a message after its first response, with the interaction’s token (the application’s ID stands where a webhook’s does).

pub fn get_application(
  client: client.RestClient,
) -> Result(json.Json, error.DuvetError)

The calling bot’s application, with the team its commands live under.

pub fn get_command(
  client: client.RestClient,
  team_id: String,
  application_id: String,
  command_id: String,
) -> Result(json.Json, error.DuvetError)

One of the application’s commands.

pub fn get_message(
  client: client.RestClient,
  application_id: String,
  token: String,
  message_ref: String,
) -> Result(json.Json, error.DuvetError)

@original, or a follow-up of the interaction, as a message.

pub fn list_commands(
  client: client.RestClient,
  team_id: String,
  application_id: String,
) -> Result(List(json.Json), error.DuvetError)

The application’s commands, as lists.

pub fn next_interaction(
  client: client.RestClient,
  application_id: String,
  wait_short: Bool,
) -> Result(option.Option(json.Json), error.DuvetError)

The bot’s next interaction, waiting up to 20 seconds for one; wait_short waits 3, for a poll that keeps a request short. None when none came.

pub fn overwrite_commands(
  client: client.RestClient,
  team_id: String,
  application_id: String,
  commands: List(json.Json),
) -> Result(List(json.Json), error.DuvetError)

Makes the application’s commands exactly commands, all of them or none.

pub fn respond(
  client: client.RestClient,
  interaction_id: String,
  token: String,
  type_: Int,
  data: option.Option(json.Json),
  with_response: Bool,
) -> Result(option.Option(json.Json), error.DuvetError)

The bot’s first response to an interaction, with its token: type is a callback type (4 a message, 5 a deferred one, 6 a deferred update, 7 an update, 9 a modal). with_response asks for the message it made.

pub fn send_message(
  client: client.RestClient,
  room_id: String,
  message: json.Json,
) -> Result(json.Json, error.DuvetError)

Sends a message to a room: its content, embeds, components and flags, as POST /api/rooms/:roomId/messages takes them.

pub fn update_command(
  client: client.RestClient,
  team_id: String,
  application_id: String,
  command_id: String,
  command: json.Json,
) -> Result(json.Json, error.DuvetError)

Edits a command; a field left out stays as it was.

✨ Search Document