View Source DiscoLog.Discord.API behaviour (disco_log v1.0.0)

A module for working with Discord REST API. https://discord.com/developers/docs/reference

This module is also a behavior. The default implementation uses the Req HTTP client. If you want to use a different client, you'll need to implement the behavior and put it under the discord_client_module configuration option.

Summary

Types

The client can be any term. It is passed as a first argument to request/4. For example, the default DiscoLog.Discord.API.Client client uses Req.Request.t() as a client.

Types

client()

@type client() :: any()

The client can be any term. It is passed as a first argument to request/4. For example, the default DiscoLog.Discord.API.Client client uses Req.Request.t() as a client.

response()

@type response() ::
  {:ok, %{status: non_neg_integer(), body: any()}} | {:error, Exception.t()}

Callbacks

client(token)

@callback client(token :: String.t()) :: %DiscoLog.Discord.API{
  client: client(),
  log?: term(),
  module: atom()
}

request(client, method, url, opts)

@callback request(
  client :: client(),
  method :: atom(),
  url :: String.t(),
  opts :: keyword()
) :: response()

Functions

create_channel(client, guild_id, body)

@spec create_channel(client(), String.t(), map()) :: response()

delete_channel(client, channel_id)

@spec delete_channel(client(), String.t()) :: response()

delete_message(client, channel_id, message_id)

@spec delete_message(client(), String.t(), String.t()) :: response()

delete_thread(client, thread_id)

@spec delete_thread(client(), String.t()) :: response()

get_channel(client, channel_id)

@spec get_channel(client(), String.t()) :: response()

get_channel_messages(client, channel_id)

@spec get_channel_messages(client(), String.t()) :: response()

get_gateway(client)

@spec get_gateway(client()) :: response()

list_active_threads(client, guild_id)

@spec list_active_threads(client(), String.t()) :: response()

list_channels(client, guild_id)

@spec list_channels(client(), String.t()) :: response()

post_message(client, channel_id, fields)

@spec post_message(client(), String.t(), Keyword.t()) :: response()

post_thread(client, channel_id, fields)

@spec post_thread(client(), String.t(), Keyword.t()) :: response()