Implementation of websocket connections to Discord.
Implementation of websocket connections to Discord.
Determines if the bot will re-shard on its own, or require user coordination. If bound to true and a re-shard occurs, the bot will make a request to discord for the new number of shards to connect with and then connect them. If bound to false, then a :re-shard event will be sent to the user library and all shards will be disconnected.
Determines if the bot will re-shard on its own, or require user coordination. If bound to true and a re-shard occurs, the bot will make a request to discord for the new number of shards to connect with and then connect them. If bound to false, then a :re-shard event will be sent to the user library and all shards will be disconnected.
Function that returns a channel that yields when it's time to identify.
Function that returns a channel that yields when it's time to identify.
Bind to to true to disconnect the entire bot after a fatal stop code.
Bind to to true to disconnect the entire bot after a fatal stop code.
(after-timeout! f timeout)
Calls a function of no arguments after the given timeout
.
Returns a channel which will have the return value of the function put on it.
Calls a function of no arguments after the given `timeout`. Returns a channel which will have the return value of the function put on it.
The maximum size of the websocket buffer
The maximum size of the websocket buffer
(connect-shards! output-ch
communication-ch
url
token
intents
shard-count
shard-ids)
Connects a set of shards with the given shard-ids
.
Returns nil.
Connects a set of shards with the given `shard-ids`. Returns nil.
(connect-websocket! buffer-size url event-ch)
Connect a websocket to the url
that puts all events onto the event-ch
.
Events are represented as vectors with a keyword for the event type and then
event data as the rest of the vector based on the type of event.
| Type | Data |
|---------------+------|
| :connect
| None.
| :disconnect
| Stop code, string message.
| :error
| Error value.
| :message
| String message.
Connect a websocket to the `url` that puts all events onto the `event-ch`. Events are represented as vectors with a keyword for the event type and then event data as the rest of the vector based on the type of event. | Type | Data | |---------------+------| | `:connect` | None. | `:disconnect` | Stop code, string message. | `:error` | Error value. | `:message` | String message.
Set of stop codes which after recieving, discljord will disconnect all shards.
Set of stop codes which after recieving, discljord will disconnect all shards.
(get-websocket-gateway url token)
Gets the shard count and websocket endpoint from Discord's API.
Takes the url
of the gateway and the token
of the bot.
Returns a map with the keys :url, :shard-count, and :session-start limit, or nil in the case of an error.
Gets the shard count and websocket endpoint from Discord's API. Takes the `url` of the gateway and the `token` of the bot. Returns a map with the keys :url, :shard-count, and :session-start limit, or nil in the case of an error.
Handles a bot-level side effect triggered by a shard. This method should never block, and should not do intense computation. Takes a place to output events to the library user, the url to connect sockets, the bot's token, the vector of shards, a vector of channels which resolve to the shard's next state, the index of the shard the effect is from, and the effect. Returns a vector of the vector of shards and the vector of shard channels.
Handles a bot-level side effect triggered by a shard. This method should never block, and should not do intense computation. Takes a place to output events to the library user, the url to connect sockets, the bot's token, the vector of shards, a vector of channels which resolve to the shard's next state, the index of the shard the effect is from, and the effect. Returns a vector of the vector of shards and the vector of shard channels.
Handles communicating to the shards
.
Takes an event
vector, a vector of shards
, and a vector of channels which
resolve to each shard's next state, and returns a vector of the vector of
shards and the vector of channels.
Handles communicating to the `shards`. Takes an `event` vector, a vector of `shards`, and a vector of channels which resolve to each shard's next state, and returns a vector of the vector of shards and the vector of channels.
Handles events which connect or disconnect the shard, returning effects.
Handles events which connect or disconnect the shard, returning effects.
Handles discord events for a specific shard, specifying effects.
Handles discord events for a specific shard, specifying effects.
Update a shard
based on a message.
Takes a shard
and msg
and returns a map with a :shard and an :effects
vector.
Update a `shard` based on a message. Takes a `shard` and `msg` and returns a map with a :shard and an :effects vector.
Processes a communication event
on the given shard
for side effects.
Returns a map with the new :shard and bot-evel :effects to process.
Processes a communication `event` on the given `shard` for side effects. Returns a map with the new :shard and bot-evel :effects to process.
Processes an event
on a given shard
for side effects.
Returns a map with the new :shard and bot-level :effects to process.
Processes an `event` on a given `shard` for side effects. Returns a map with the new :shard and bot-level :effects to process.
Updates a shard
based on shard events.
Takes a shard
and a shard event vector and returns a map of the new state of
the shard and zero or more events to process.
Updates a `shard` based on shard events. Takes a `shard` and a shard event vector and returns a map of the new state of the shard and zero or more events to process.
(make-shard intents id shard-count)
Creates a new shard with the given id
and shard-count
.
Creates a new shard with the given `id` and `shard-count`.
Set of stop codes after which a resume isn't possible.
Set of stop codes after which a resume isn't possible.
Stop codes which Discord will send when the bot needs to be re-sharded.
Stop codes which Discord will send when the bot needs to be re-sharded.
(run-on-agent-with-limit a f millis)
Runs the given function on the agent, then other actions wait millis
.
Runs the given function on the agent, then other actions wait `millis`.
(should-resume? shard)
Returns if a shard should try to resume.
Returns if a shard should try to resume.
(step-shard! shard url token)
Starts a process to step a shard
, handling side-effects.
Returns a channel which will have a map with the new :shard
and a vector of
:effects
for the entire bot to respond to placed on it after the next item
the socket may respond to occurs.
Starts a process to step a `shard`, handling side-effects. Returns a channel which will have a map with the new `:shard` and a vector of `:effects` for the entire bot to respond to placed on it after the next item the socket may respond to occurs.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close