Class: Discordrb::Await

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/await.rb

Overview

Class that represents an await to wait for a further event

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bot, key, type, attributes, block = nil) ⇒ Await

Returns a new instance of Await.



6
7
8
9
10
11
12
# File 'lib/discordrb/await.rb', line 6

def initialize(bot, key, type, attributes, block = nil)
  @bot = bot
  @key = key
  @type = type
  @attributes = attributes
  @block = block
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/discordrb/await.rb', line 4

def attributes
  @attributes
end

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/discordrb/await.rb', line 4

def key
  @key
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/discordrb/await.rb', line 4

def type
  @type
end

Instance Method Details

#match(event) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/discordrb/await.rb', line 14

def match(event)
  dummy_handler = @bot.handler_class(@type).new(@attributes, @bot)
  return [nil, nil] unless dummy_handler.matches?(event)

  should_delete = true if (@block && @block.call(event) != false) || !@block

  [@key, should_delete]
end