Skip to content

Deployment & Configuration

Options

OptionTypeDefaultDescription
botmodulerequiredBot module with use Lingo.Bot
tokenstringrequiredBot token
intents[atom] | integer[:guilds, :guild_messages]Gateway intents
cachekeyword | false[]Cache config, or false to disable (see Cache)
shardingkeyword[]Sharding config (see below)
presencekeyword[]Initial presence (see below)

Sharding

Lingo handles sharding automatically by asking the gateway for the recommended shard count.

elixir
# Auto (default)
{Lingo, bot: MyBot.Bot, token: token, intents: intents}

# Fixed shard count
{Lingo, bot: MyBot.Bot, token: token, intents: intents,
 sharding: [count: 4]}

# Specific shards for multi-node setups (count is required with ids)
{Lingo, bot: MyBot.Bot, token: token, intents: intents,
 sharding: [count: 4, ids: [0, 1]]}
OptionTypeDefault
countinteger | :auto:auto
ids[integer] | :all:all

Shard Management

elixir
Lingo.shard_count()                    # total shard count
Lingo.shard_for_guild(guild_id)        # which shard handles this guild
Lingo.restart_shard(shard_id)          # restart a specific shard
Lingo.reshard()                        # re-query and restart all shards
Lingo.latency(shard_id)               # heartbeat latency in ms
Lingo.latencies()                      # %{shard_id => latency_ms} for all shards

reshard/0 only works with auto shard count. If you set a manual count, it's a no-op.

Presence

Set the bot's status on connect:

elixir
{Lingo,
 bot: MyBot.Bot,
 token: token,
 intents: intents,
 presence: [status: :online, text: "with Elixir"]}
OptionTypeDefault
statusatom:online
textstringnil
activityActivity structnil

text sets a "Playing" activity. For more control, pass a struct:

elixir
presence: [
  status: :dnd,
  activity: %Lingo.Type.Activity{name: "music", type: :listening}
]

Activity types: :playing, :streaming, :listening, :watching, :custom, :competing.

Status values: :online, :idle, :dnd, :invisible.

Updating at Runtime

elixir
Lingo.update_presence(:online, text: "something new")
Lingo.update_presence(:idle)
Lingo.update_presence(:dnd, activity: %Lingo.Type.Activity{name: "music", type: :listening})

Broadcasts to all shards.