glyph/clients/bot

This contains the client with functions specifically made for Bot users.

Types

Generic bot error

pub type BotError {
  BotError(message: String)
}

Constructors

  • BotError(message: String)

Functions

pub fn initialize(bot: BotClient) -> Result(BotClient, BotError)

Initialize a supervisor that manages the WebSocket process (aka the bot)

pub fn new(
  token: String,
  client_url: String,
  client_version: String,
) -> BotClient

Construct a new BotClient

pub fn on_message_create(
  bot: BotClient,
  callback: fn(BotClient, Message) -> Result(Nil, DiscordError),
) -> BotClient

Register a handler for the MESSAGE_CREATE gateway event.

The callback function must accept a BotClient as its first argument, and is provided a Message argument as part of the MESSAGE_CREATE event.

pub fn send(
  bot: BotClient,
  channel_id: String,
  message: MessagePayload,
) -> Result(Response(String), Error)

Send a message to a channel.

For constructing a message, see the message builder. For constructing an embed, see the embed builder.

pub fn set_intents(
  b: BotClient,
  intents: List(GatewayIntent),
) -> BotClient

Register intents for your bot

Search Document