class DiscordMiddleware::CachedEvent

Overview

When a message is passed through this middleware, it caches several common properties one might make for typical commands:

client.on_message_create(
  DiscordMiddleware::Prefix.new("!info"),
  DiscordMiddleware::CachedEvent.new) do |payload, context|
  cached = context[DiscordMiddleware::CachedEvent::Result]
  cached.channel      # => Channel
  cached.guild        # => Guild?
  cached.member       # => Member?
  cached.member_roles # => Array(Role)?
end

If the cache is enabled on the client (recommended) it will be used.

Included Modules

Defined in:

discordcr-middleware/middleware/cached_event.cr

Instance Method Summary

Instance Method Detail

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

[View source]