crux_gateway v0.1.4 Crux.Gateway View Source
Main entry point to start the Gateway connection.
Required for this to run are:
:tokento identify with, you can get your bot’s from here.
You want to keep that token secret at all times.
:urlto connect to. Probably something likewss://gateway.discord.gg.
(Do not append query strings)
You usually want to GET the url via
/gateway/botalong the recommended shard count.
:shard_countyou plan to run altogether.
Can and probably should be retrieved via
/gateway/bot.
- Optionally
:shards, which has to be a list of numbers and ranges.
Examples: [1..3] [1, 2, 3] [1..3, 8, 9]
If omitted all shards will be run.
- Optionally
:dispatcher, which has to be a validGenStage.Dispatcheror a tuple of one and initial state.
See
Crux.Gateway.Connection.Producerfor more info.
- Optionally
:presence, which is used for the initial presence of every session.
This should be a presence or a function with an arity of one (the shard id) and returning a presence.
If a function, it will be invoked whenever a shard is about to identify.
If omitted the presence will default to online and no game.
Link to this section Summary
Types
Used to specify or override gateway options when initially starting the connection
Functions
Initialises the connection(s) and actually starts the gateway
Link to this section Types
gateway_options() :: %{
optional(:token) => String.t(),
optional(:url) => String.t(),
optional(:shard_count) => pos_integer(),
optional(:shards) => [non_neg_integer() | Range.t()],
optional(:dispatcher) =>
GenStage.Dispatcher.t() | {GenStage.Dispatcher.t(), term()},
optional(:presence) => (non_neg_integer() -> map()) | map()
}
Used to specify or override gateway options when initially starting the connection.
See start/1
Link to this section Functions
start(args :: gateway_options()) :: [Supervisor.on_start_child()]
Initialises the connection(s) and actually starts the gateway.
You can specify or override :token, :url, :shard_count and :shards here via t:gateway_options.