discord_gleam/bot

Types

The Bot type holds bot data used by a lot of high-level functions

pub type Bot {
  Bot(
    token: String,
    client_id: snowflake.Snowflake(snowflake.Application),
    intents: intents.Intents,
    cache: Cache,
    message_cache_limit: Int,
    subject: process.Subject(BotMessage),
  )
}

Constructors

Used to send user messages to the websocket process

pub type BotMessage {
  SendPacket(packet: String)
}

Constructors

  • SendPacket(packet: String)

The cache currently only stores messages, which can be used to for example get deleted messages

pub type Cache {
  Cache(
    messages: booklet.Booklet(
      dict.Dict(
        snowflake.Snowflake(snowflake.Message),
        message.MessagePacketData,
      ),
    ),
  )
}

Constructors

Values

pub fn new(token: String, client_id: String) -> Bot

Create a new bot instance.

Example:

import discord_gleam/bot

fn main() {
  let bot = bot.new("TOKEN", "CLIENT_ID")
}
pub fn send_packet(bot: Bot, packet: String) -> Nil

Used to send a packet on the websocket to discord
Primarily made to be used internally

pub fn with_intents(bot: Bot, intents: intents.Intents) -> Bot

Sets the intents for the bot.
This can only be used before the bot is started, and is meant to use while building the bot

Example:

import discord_gleam/bot
import discord_gleam/discord/intents

fn main() {
  let bot =
    bot.new(token, client_id)
    |> bot.with_intents(intents.all())
}
pub fn with_message_cache_limit(bot: Bot, limit: Int) -> Bot

Sets the message cache size limit for the bot, default is 1000 messages.

Search Document