Client
Ekztazy.Client
— TypeClient(
token::String
application_id::Snowflake
intents::Int;
presence::Union{Dict, NamedTuple}=Dict(),
strategies::Dict{DataType, <:CacheStrategy}=Dict(),
version::Int=9,
) -> Client
A Discord bot. Client
s can connect to the gateway, respond to events, and make REST API calls to perform actions such as sending/deleting messages, kicking/banning users, etc.
Bot Token
A bot token can be acquired by creating a new application here. Make sure not to hardcode the token into your Julia code! Use an environment variable or configuration file instead.
Application ID
The application id for your bot can be found here. Make sure not to hardcode the application id into your Julia code! Use an environment variable or configuration file instead.
Intents
Integer representing intents. More information here.
Presence
The presence
keyword sets the bot's presence upon connection. It also sets defaults for future calls to set_game
. The schema here must be followed.
Cache Control
By default, most data that comes from Discord is cached for later use. However, to avoid memory leakage, not all of it is kept forever. The default setings are to keep everything but Message
s, which are deleted after 6 hours, forever. Although the default settings are sufficient for most workloads, you can specify your own strategies per type with the strategies
keyword. Keys can be any of the following:
For potential values, see CacheStrategy
.
The cache can also be disabled/enabled permanently and temporarily as a whole with enable_cache!
and disable_cache!
.
API Version
The version
keyword chooses the Version of the Discord API to use. Using anything but 9
is not officially supported by the Ekztazy.jl developers.
Sharding
Sharding is handled automatically. The number of available processes is the number of shards that are created. See the sharding example for more details.
Ekztazy.enable_cache!
— Functionenable_cache!(c::Client)
enable_cache!(f::Function c::Client)
Enable the cache. do
syntax is also accepted.
Ekztazy.disable_cache!
— Functiondisable_cache!(c::Client)
disable_cache!(f::Function, c::Client)
Disable the cache. do
syntax is also accepted.
Ekztazy.me
— Functionme(c::Client) -> Nullable{User}
Get the Client
's bot user.
Gateway
Base.open
— Functionopen(c::Client; delay::Period=Second(7))
Connect a Client
to the Discord gateway.
The delay
keyword is the time between shards connecting. It can be increased from its default if you are using multiple shards and frequently experiencing invalid sessions upon connection.
Base.isopen
— Functionisopen(c::Client) -> Bool
Determine whether the Client
is connected to the gateway.
Base.close
— Functionclose(c::Client)
Disconnect the Client
from the gateway.
Base.wait
— Functionwait(c::Client)
Wait for an open Client
to close.
Ekztazy.request_guild_members
— Functionrequest_guild_members(
c::Client,
guilds::Union{Integer, Vector{<:Integer};
query::AbstractString="",
limit::Int=0,
) -> Bool
Request offline guild members of one or more Guild
s. on_guild_members_chunk!
events are sent by the gateway in response. More details here.
Ekztazy.update_voice_state
— Functionupdate_voice_state(
c::Client,
guild::Integer,
channel::Nullable{Integer},
mute::Bool,
deaf::Bool,
) -> Bool
Join, move, or disconnect from a voice channel. A VoiceStateUpdate
event is sent by the gateway in response. More details here.
Ekztazy.update_status
— Functionupdate_status(
c::Client,
since::Nullable{Int},
activity::Nullable{Activity},
status::Union{PresenceStatus, AbstractString},
afk::Bool,
) -> Bool
Indicate a presence or status update. A PresenceUpdate
event is sent by the gateway in response. More details here.
Ekztazy.heartbeat_ping
— Functionheartbeat_ping(c::Client) -> Nullable{Period}
Get the Client
's ping time to the gateway. If the client is not connected, or no heartbeats have been sent/acknowledged, nothing
is returned.
Ekztazy.start
— Functionstart(c::Client)
Creates a handler to generate ApplicationCommand
s.
Creates handlers for GuildCreate events.
Calls open
then wait
on the Client
.
Caching
Ekztazy.CacheStrategy
— TypeA method of handling cache insertion and eviction.
Ekztazy.CacheForever
— TypeCacheForever() -> CacheForever
Store everything and never evict items from the cache.
Ekztazy.CacheNever
— TypeCacheNever() -> CacheNever
Don't store anything in the cache.
Ekztazy.CacheTTL
— TypeCacheTTL(ttl::Period) -> CacheTTL
Evict items from the cache after ttl
has elapsed.
Ekztazy.CacheLRU
— TypeCacheLRU(size::Int) -> CacheLRU
Evict the least recently used item from the cache when there are more than size
items.
Ekztazy.CacheFilter
— TypeCacheFilter(f::Function) -> CacheFilter
Only store value v
at key k
if f(v) === true
(k
is always v.id
).