Module: Discorb::Extension Abstract

Defined in:
lib/discorb/extension.rb

Overview

This module is abstract.

Abstract class to make extension. Include from this module to make your own extension.

See Also:

Instance Method Summary collapse

Instance Method Details

#eventsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/discorb/extension.rb', line 15

def events
  return @events if @events

  ret = {}
  self.class.events.each do |event, handlers|
    ret[event] = handlers.map do |handler|
      Discorb::EventHandler.new(
        proc do |*args, **kwargs|
          instance_exec(*args, **kwargs, &handler[2])
        end,
        handler[0],
        handler[1]
      )
    end
  end
  @events = ret
end

#initialize(client) ⇒ Object



11
12
13
# File 'lib/discorb/extension.rb', line 11

def initialize(client)
  @client = client
end