Helpers
Discord.Permission — Type.Bitwise permission flags. More details here.
Discord.has_permission — Function.has_permission(perms::Integer, perm::Permission) -> BoolDetermine whether a bitwise OR of permissions contains one Permission.
Example
julia> has_permission(0x0420, PERM_VIEW_CHANNEL)
true
julia> has_permission(0x0420, PERM_ADMINISTRATOR)
false
julia> has_permission(0x0008, PERM_MANAGE_ROLES)
trueDiscord.permissions_in — Function.permissions_in(m::Member, g::Guild, ch::DiscordChannel) -> Int64Compute a Member's Permissions in a DiscordChannel.
Discord.reply — Function.reply(
c::Client,
m::Message,
content::Union{AbstractString, AbstractDict, NamedTuple, Embed};
at::Bool=false,
) -> Future{Response}Reply (send a message to the same DiscordChannel) to a Message. If at is set, then the message is prefixed with the sender's mention.
Discord.split_message — Function.split_message(text::AbstractString) -> Vector{String}Split a message into 2000-character chunks, preserving formatting.
Examples
```jldoctest; setup=:(using Discord) julia> split_message("foo") 1-element Array{String,1}: "foo"
julia> split_message(repeat('.', 1995) * "hello, world")[2] "hello, world"
Discord.plaintext — Function.plaintext(m::Message) -> String
plaintext(c::Client, m::Message) -> StringGet the Message contents with any User mentions replaced with their plaintext. If a Client is provided, DiscordChannels Role are also replaced. However, only channels and roles stored in state are replaced; no API requests are made.
Discord.upload_file — Function.upload_file(c::Client, ch::DiscordChannel, path::AbstractString; kwargs...) -> MessageSend a Message with a file Attachment. Any keywords are passed on to create_message.
Discord.set_game — Function.set_game(
c::Client,
game::AbstractString;
type::Union{ActivityType, Int}=AT_GAME,
since::Nullable{Int}=c.presence["since"],
status::Union{PresenceStatus, AbstractString}=c.presence["status"],
afk::Bool=c.presence["afk"],
kwargs...,
) -> BoolShortcut for update_status to set the Client's Activity. Any additional keywords are passed into the activity section.
Discord.@fetch — Macro.@fetch [functions...] blockWrap all calls to the specified CRUD functions (create, retrieve, update, and delete) with fetch inside a block. If no functions are specified, all CRUD functions are wrapped.
Examples
Wrapping all CRUD functions:
@fetch begin
guild_resp = create(c, Guild; name="foo")
guild_resp.ok || error("Request for new guild failed")
channel_resp = retrieve(c, DiscordChannel, guild_resp.val)
endWrapping only calls to retrieve:
@fetch retrieve begin
resp = retrieve(c, DiscordChannel, 123)
future = create(c, Message, resp.val; content="foo") # Behaves normally.
endDiscord.@fetchval — Macro.Discord.@deferred_fetch — Macro.@deferred_fetch [functions...] blockIdentical to @fetch, but Futures are not fetched until the end of the block. This is more efficient, but only works when there are no data dependencies in the block.
Examples
This will work:
@deferred_fetch begin
guild_resp = create(c, Guild; name="foo")
channel_resp = retrieve(c, DiscordChannel, 123)
endThis will not, because the second call is dependent on the first value:
@deferred_fetch begin
guild_resp = create(c, Guild; name="foo")
channels_resp = retrieve(c, DiscordChannel, guild_resp.val)
endDiscord.@deferred_fetchval — Macro.@deferred_fetchval [functions...] blockIdentical to @deferred_fetch, but Futures have fetchval called on them instead of fetch.