class DiscordMiddleware::Time

Overview

This middleware provides a method of executing some block after a given amount of time from receiving an event.

delayed = DiscordMiddleware::Time.new(5.seconds) do |context|
  channel_id = context.payload.channel_id
  context.client.create_message(channel_id, "I'm back!")
end

client.on_message_create(delayed) do |payload, context|
  channel_id = payload.channel_id
  context.client.create_message(channel_id, "Going away for 5 seconds..")
end

Defined in:

discordcr-middleware/middleware/time.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(delay : ::Time::Span, &block : Discord::Message, Discord::Context -> ) #

[View source]

Instance Method Detail

def call(payload : Discord::Message, context : Discord::Context, &block) #

[View source]