module Discord

Defined in:

discordcr.cr
discordcr/cache.cr
discordcr/client.cr
discordcr/dca.cr
discordcr/errors.cr
discordcr/mappings/channel.cr
discordcr/mappings/converters.cr
discordcr/mappings/gateway.cr
discordcr/mappings/guild.cr
discordcr/mappings/invite.cr
discordcr/mappings/oauth2.cr
discordcr/mappings/permissions.cr
discordcr/mappings/rest.cr
discordcr/mappings/user.cr
discordcr/mappings/voice.cr
discordcr/mappings/vws.cr
discordcr/mappings/webhook.cr
discordcr/paginator.cr
discordcr/rest.cr
discordcr/snowflake.cr
discordcr/sodium.cr
discordcr/version.cr
discordcr/voice.cr
discordcr/websocket.cr

Constant Summary

DISCORD_EPOCH = 1420070400000_u64
Log = ::Log.for("discord")
VERSION = "0.4.0"

Class Method Summary

Class Method Detail

def self.every(time_span : Time::Span, &) #

Runs the given block every time_span. This method takes into account the execution time for the block to keep the intervals accurate.

Note that if the block takes longer to execute than the given time_span, there will be no delay: the next iteration follows immediately, with no attempt to get in sync.


[View source]
def self.shard_id(guild_id : UInt64 | Snowflake, total_shards : Int32) #

Calculates the shard ID that would receive the gateway events from a guild with the given guild_id, based on the total number of shards.


[View source]
def self.timed_run(total_time : Time::Span, &) #

Utility function that runs the given block and measures the time it takes, then sleeps the given time minus that time. This is useful for voice code because (in most cases) voice data should be sent to Discord at a rate of one frame every 20 ms, and if the processing and sending takes a certain amount of time, then noticeable choppiness can be heard.


[View source]