API

Discorder.AbstractTriggerType
AbstractTrigger

A trigger is used to represent data that can be used to determine whether an event handler should be fired. For example, a regex-based command trigger may store a Regex object that can be used to match messages.

source
Discorder.create_eventMethod
create_event_object(tracker::GatewayTracker, event_type::AbstractString, json::Optional{Abstract)

Create an event object by parsing the gateway event as JSON string.

source
Discorder.get_loggerMethod
get_logger(filename; debug::Bool)

Return a custom logger that write to the specified log file. A timestamp is automatically injected.

Arguments

  • file_path: path of log file

Keyword arguments

  • debug: turn on debug logging (default = false)
source
Discorder.jsonMethod

Convert object to JSON formatted string.

  • Fields with missing values are excluded.
  • Fields with nothing values are included as null.
source
Discorder.publishMethod
publish(publisher::AbstractEventPublisher, event::Event)

Publish an event via the provided event publisher.

source
Discorder.safe_parse_jsonMethod
safe_parse_json(tracker::GatewayTracker, json::AbstractString, T::DataType)

Parse a JSON string into an expected type T, which is configured using StructType traits. Returns nothing if the string cannot be parsed for some reasons. Throw exception only during fail_on_error mode.

source
Discorder.safe_waitMethod
safe_wait(task::Optional{Task})

Wait for a task for finish synchronously. Unlike wait, it is meant to be safe and never throw, except during fail_on_error mode. Always return nothing.

source
Discorder.serveMethod
serve(;
    client::BotClient=BotClient(),
    tracker_ref=Ref{GatewayTracker}(),
    config_file_path::Optional{AbstractString}=nothing,
)

Run control plane in a loop so that we can actually auto-recover when bad things happen.

source
Discorder.should_triggerFunction

Return a vector of arguments that is passed to the user function when triggered, or nothing if the trigger should not be fired.

source
Discorder.show_errorMethod
show_error(ex::Exception)

Display an error in the log with backtrace. This is usefulf for debugging purpose.

source
Discorder.waterfallMethod
waterfall(f, xs)

Apply function f to each element of collection xs iteratively and return the very first application where no exception was thrown. If every application throws exception then the last exception is re-thrown.

source