REST API

Response

Ekztazy.ResponseType

A wrapper around a response from the REST API. Every function which wraps a Discord REST API endpoint returns a Future which will contain a value of this type. To retrieve the Response from the Future, use fetch. See also: fetchval.

Fields

  • val::Nullable{T}: The object contained in the HTTP response. For example, for a call to get_channel_message, this value will be a Message.
  • ok::Bool: The state of the request. If true, then it is safe to access val.
  • http_response::Nullable{HTTP.Messages.Response}: The underlying HTTP response, if a request was made.
  • exception::Nullable{Exception}: The caught exception, if one is thrown.

Examples

Multiple API calls which immediately return Futures and can be awaited:

futures = map(i -> create_message(c, channel_id; content=string(i)), 1:10);
other_work_here()
resps = fetch.(futures)

Skipping error checks and returning the value directly:

guild = fetchval(create_guild(c; name="foo"))
source
Ekztazy.fetchvalFunction
fetchval(f::Future{Response{T}}) -> Nullable{T}

Shortcut for fetch(f).val: Fetch a Response and return its value. Note that there are no guarantees about the response's success and the value being returned, and it discards context that can be useful for debugging, such as HTTP responses and caught exceptions.

source

CRUD API

On top of functions for accessing individual endpoints such as get_channel_messages, Ekztazy.jl also offers a unified API with just four functions. Named after the CRUD model, they cover most of the Discord REST API and allow you to write concise, expressive code, and forget about the subtleties of endpoint naming. The argument ordering convention is roughly as follows:

  1. A Client, always.
  2. For cases when we don't yet have the entity to be manipulated (usually create and retrieve), the entity's type. If we do have the entity (update and delete), the entity itself.
  3. The remaining positional arguments supply whatever context is needed to specify the entity. For example, sending a message requires a DiscordChannel parameter.
  4. Keyword arguments follow (usually for create and update).
Ekztazy.createFunction
create(c::Client, ::Type{T}, args...; kwargs...) -> Future{Response}

Create, add, send, etc.

Examples

Sending a Message:

create(c, Message, channel; content="foo")

Creating a new DiscordChannel:

create(c, DiscordChannel, guild; name="bar")

Banning a Member:

create(c, Ban, guild, member; reason="baz")
source
Ekztazy.retrieveFunction
retrieve(c::Client, ::Type{T}, args...; kwargs...) -> Future{Response{T}}

Retrieve, get, list, etc.

Examples

Getting the Client's User:

retrieve(c, User)

Getting a Guild's DiscordChannels:

retrieve(c, DiscordChannel, guild)

Getting an Invite to a Guild by code:

retrieve(c, Invite, "abcdef")
source
Ekztazy.updateFunction
update(c::Client, x::T, args...; kwargs...) -> Future{Response}

Update, edit, modify, etc.

Examples

Editing a Message:

update(c, message; content="foo2")

Modifying a Webhook:

update(c, webhook; name="bar2")

Updating a Role:

update(c, role, guild; permissions=8)
source
Ekztazy.deleteFunction
delete(c::Client, x::T, args...) -> Future{Response}

Delete, remove, discard, etc.

Examples

Kicking a Member:

delete(c, member)

Unbanning a Member:

delete(c, ban, guild)

Deleting all Reactions from a Message (note: this is the only update/delete method which takes a type parameter):

delete(c, Reaction, message)
source
Ekztazy.obtainFunction
obtain(c::Client, ::Type{T}, args...; kwargs...) -> T

Equivalent to retrieve, but blocks and returns the object of type T

source

The full list of types available to be manipulated is:

Endpoints

Functions which wrap REST API endpoints are named and sorted according to the Discord API documentation. When a function accepts keyword arguments, the docstring will include a link to the Discord documentation which indicates the expected keys and values. Remember that the return types annotated below are not the actual return types, but the types of Response that the returned Futures will yield.

Audit Log

Channel

Ekztazy.create_reactionFunction
create_reaction(c::Client, channel::Integer, message::Integer, emoji::StringOrChar)

React to a Message. If emoji is a custom Emoji, it should be formatted "name:id".

source

Emoji

Guild

Invite

User

Voice

Webhook

Interaction

Ekztazy.respond_to_interactionFunction
respond_to_interaction(c::Client, int_id::Snowflake, int_token::String; kwargs...) -> Message

Respond to an interaction with code 4.

source
Ekztazy.create_followup_messageFunction
create_followup_message(c::Client, int_id::Snowflake, int_token::String; kwargs...) -> Message

Creates a followup message for an interaction.

source
Ekztazy.ack_interactionFunction
ack_interaction(c::Client, int_id::Snowflake, int_token::String; kwargs...)

Respond to an interaction with code 5.

source
Ekztazy.update_ack_interactionFunction
update_ack_interaction(c::Client, int_id::Snowflake, int_token::String; kwargs...) -> Message

Respond to an interaction with code 6.

source
Ekztazy.update_message_intFunction
update_message_int(c::Client, int_id::Snowflake, int_token::String; kwargs...)

Respond to an interaction with code 7.

source
Missing docstring.

Missing docstring for create_followup_message. Check Documenter's build log for details.

Ekztazy.edit_interactionFunction
edit_interaction(c::Client, int_id::Snowflake, int_token::String; kwargs...)

Edit a followup message for an interaction.

source