Class Method Summary
.every(time_span : Time::Span, &block)
Runs the given block every time_span.
.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.
.timed_run(total_time : Time::Span, &block)
Utility function that runs the given block and measures the time it takes, then sleeps the given time minus that time.
Class Method Detail
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.
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.